Sams Teach Yourself C in 21 Days
The first string. The second string. Enter number of characters to compare, 0 to exit. 3 Comparing 3 characters, strncmp() retur ...
Manipulating Strings 495 17 strspn() strpbrk() strstr() Thestrchr()Function .................................................. ...
23: printf(“The character %c was not found.”, ch); 24: else 25: printf(“The character %c was found at position %d.\n”, 26: ch, l ...
Manipulating Strings 497 17 LISTING17.10 strcspn.c. Searching for a set of characters with strcspn() 1: /* Searching with strcsp ...
Thestrspn()Function ................................................................................ This function is related to ...
Manipulating Strings 499 17 This program is similar to the previous example, except that it calls strspn() instead of strcspn()o ...
10: /* Input the strings. */ 11: 12: printf(“Enter the string to be searched: “); 13: gets(buf1); 14: printf(“Enter the target s ...
Manipulating Strings 501 17 String Conversions ................................................................................. ...
Enter a line of text, a blank to exit. Bradley L. Jones bradley l. jones BRADLEY L. JONES Enter a line of text, a blank to exit. ...
Manipulating Strings 503 17 char *strset(char *str, int ch); char *strnset(char *str, int ch, size_t n); The function strset()ch ...
String-to-Number Conversions .......................................................................... Sometimes, you will need ...
Manipulating Strings 505 17 The values returned by atol()would be the same as shown for atoi()in Table 17.2, except that each re ...
12: while (1) 13: { 14: printf(“\nEnter the string to convert (blank to exit): “); 15: gets(buf); 16: 17: if ( strlen(buf) == 0 ...
Manipulating Strings 507 17 In the preceding line,chis the character being tested. The return value is TRUE(nonzero) if the cond ...
12: x = get_int(); 13: 14: printf(“You entered %d.\n”, x); 15: } 16: 17: int get_int(void) 18: { 19: int ch, i, sign = 1; 20: 21 ...
Manipulating Strings 509 17 60: if (ch != EOF) 61: ungetc(ch, stdin); 62: 63: /* Return the input value. */ 64: 65: return i; 66 ...
The heart of the function is the forloop on lines 50 and 51, which continues to get char- acters as long as the characters gotte ...
Manipulating Strings 511 17 10: 11: while (1) 12: { 13: puts(“\nEnter a line of text, a blank to exit.”); 14: gets(buf); 15: 16: ...
Summary ............................................................................................................ Today’s les ...
Manipulating Strings 513 17 Quiz ............................................................................................... ...
«
22
23
24
25
26
27
28
29
30
31
»
Free download pdf