1234

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 1234 as PDF for free.

More details

  • Words: 178
  • Pages: 2
Angel Calderon Wednesday, April 01, 2009 Chapter 09 Self-Checks 9.1 2. printf starts from the non spaced character till it finds the null character ‘\0’. 9.2 // // // //

Name: Angel Calderon Date: Tuesday, March 03, 2009 Course: COP 1220 Chapter 7 Review Question 6

#include "stdafx.h" #include "conio.h" #include "string.h" char *trim_blanks(char *trimmed, const char *to_trim) { /*Find subscript of the first nonblank in to_trim*/ int first_nonblank = 0; for(int x=0;x<=strlen(to_trim);x++) { if(to_trim[x] != ' ') { first_nonblank = x; break; } } /*Find subscript of last nonbalnk in to_trim*/ int last_nonblank = 0; for(int x=0;x<=strlen(to_trim);x++) { if(to_trim[x] == '\0') { break; } else if(to_trim[x] != ' ') { last_nonblank = x; } } /*Use strncpy to store trimmed string in trimmed*/ int next = 0; for(int x = first_nonblank; x<= last_nonblank; x++) { strncpy(&trimmed[next], &to_trim[x], last_nonblank ); next+=1; } trimmed[next+1] = '\0'; return " ";

}

9.3

Strcat(tmp, press[7]) parameter 2 is not a string or address but a character. 9.4 Both Chapter Review 1. 2. 3. 4.

Yes Yes Yes Yes

9. Yes 10.

Related Documents

1234
June 2020 12
1234
November 2019 33
1234
November 2019 29
1234
July 2020 2
1234
June 2020 3
1234
October 2019 30