标签:enter get tin code clu des 空间 war cal
// strcpy.c #include <syslib.h> #include <string.h> main() { char *s="Golden Global View"; char d[20]; clrscr(); strcpy(d,s); printf("%s",d); getchar(); return 0; }
1 // strcat.c 2 #include <syslib.h> 3 #include <string.h> 4 main() 5 { 6 char d[20]="Golden Global"; 7 char *s=" View"; 8 clrscr(); 9 strcat(d,s); 10 printf("%s",d); 11 getchar(); 12 return 0; 13 }
// strlen.c #include <syslib.h> #include <string.h> main() { char *s="Golden Global View"; clrscr(); printf("%s has %d chars",s,strlen(s)); getchar(); return 0; }
// strncat.c #include <syslib.h> #include <string.h> main() { char d[20]="Golden Global"; char *s=" View WinIDE Library"; clrscr(); strncat(d,s,5); printf("%s",d); getchar(); return 0; }
1 // strncpy.c 2 #include <syslib.h> 3 #include <string.h> 4 main() 5 { 6 char *s="Golden Global View"; 7 char *d="Hello, GGV Programmers"; 8 char *p=strdup(s); 9 clrscr(); 10 textmode(0x00); // enable 6 lines mode 11 strncpy(d,s,strlen(s)); 12 printf("%s\n",d); 13 strncpy(p,s,strlen(d)); 14 printf("%s",p); 15 free(p); 16 getchar(); 17 return 0; 18 }
1 #include <stdio.h> 2 #include <string.h> 3 #include <alloc.h> 4 int main(void) 5 { 6 char *string1 = "1234567890"; 7 char *string2 = "747DC8"; 8 int length; 9 length = strcspn(string1, string2); 10 printf("Character where strings intersect is at position %dn", length); 11 return 0; 12 }
1 #include <stdio.h> 2 #include <string.h> 3 #include <alloc.h> 4 int main(void) 5 { 6 char *dup_str, *string = "abcde"; 7 dup_str = strdup(string); 8 printf("%sn", dup_str); 9 free(dup_str); 10 return 0; 11 }
#include <string.h> #include <stdio.h> int main(void) { char *buf1 = "BBB", *buf2 = "bbb"; int ptr; ptr = stricmp(buf2, buf1); if (ptr > 0) printf("buffer 2 is greater than buffer 1n"); if (ptr < 0) printf("buffer 2 is less than buffer 1n"); if (ptr == 0) printf("buffer 2 equals buffer 1n"); return 0; }
1 #include <stdio.h> 2 #include <errno.h> 3 int main(void) 4 { 5 char *buffer; 6 buffer = strerror(errno); 7 printf("Error: %sn", buffer); 8 return 0; 9 }
1 #include <string.h> 2 #include <stdio.h> 3 int main(void) 4 { 5 char *buf1 = "BBB", *buf2 = "bbb"; 6 int ptr; 7 ptr =strcmp(buf2, buf1); 8 if (ptr > 0) 9 printf("buffer 2 is greater than buffer 1n"); 10 if (ptr < 0) 11 printf("buffer 2 is less than buffer 1n"); 12 if (ptr == 0) 13 printf("buffer 2 equals buffer 1n"); 14 return 0; 15 }
#include <string.h> #include <stdio.h> int main(void) { char *buf1 = "BBBccc", *buf2 = "bbbccc"; int ptr; ptr = strncmp(buf2,buf1,3); if (ptr > 0) printf("buffer 2 is greater than buffer 1n"); if (ptr < 0) printf("buffer 2 is less than buffer 1n"); if (ptr == 0) printf("buffer 2 equals buffer 1n"); return 0; }
1 #include <string.h> 2 #include <stdio.h> 3 int main(void) 4 { 5 char *buf1 = "BBBccc", *buf2 = "bbbccc"; 6 int ptr; 7 ptr =strnicmp(buf2, buf1, 3); 8 if (ptr > 0) 9 printf("buffer 2 is greater than buffer 1n"); 10 if (ptr < 0) 11 printf("buffer 2 is less than buffer 1n"); 12 if (ptr == 0) 13 printf("buffer 2 equals buffer 1n"); 14 return 0; 15 }
#include <stdio.h> #include <string.h> int main(void) { char letter = ‘x‘; printf("string beforestrnset: %sn", string); strnset(string, letter, 13); printf("string afterstrnset: %sn", string); return 0; }
1 #include <stdio.h> 2 #include <string.h> 3 int main(void) 4 { 5 char *string1 = "abcdefghijklmnopqrstuvwxyz"; 6 char *string2 = "onm"; 7 char *ptr; 8 ptr = strpbrk(string1, string2); 9 if (ptr) 10 printf("strpbrk found first character: %c\n", *ptr); 11 else 12 printf("strpbrk didn‘t find character in setn"); 13 return 0; 14 }
1 #include <string.h> 2 #include <stdio.h> 3 int main(void) 4 { 5 char string[15]; 6 char *ptr, c = ‘r‘; 7 strcpy(string, "This is a string"); 8 ptr = strrchr(string, c); 9 if (ptr) 10 printf("The character %c is at position: %dn", c, ptr-string); 11 else 12 printf("The character was not foundn"); 13 return 0; 14 }
1 #include <string.h> 2 #include <stdio.h> 3 int main(void) 4 { 5 char *forward = "string"; 6 printf("Before strrev(): %sn", forward); 7 strrev(forward); 8 printf("After strrev(): %sn", forward); 9 return 0; 10 }
1 #include <stdio.h> 2 #include <string.h> 3 int main(void) 4 { 5 char string[10] = "123456789"; 6 char symbol = ‘c‘; 7 printf("Beforestrset(): %sn", string); 8 strset(string, symbol); 9 printf("Afterstrset(): %sn", string); 10 return 0; 11 }
1 #include <stdio.h> 2 #include <string.h> 3 #include <alloc.h> 4 int main(void) 5 { 6 char *string1 = "1234567890"; 7 char *string2 = "123DC8"; 8 int length; 9 length = strspn(string1, string2); 10 printf("Character where strings differ is at position %dn", length); 11 return 0; 12 }
1 #include <stdio.h> 2 #include <string.h> 3 int main(void) 4 { 5 char *str1 = "Borland International", *str2 = "nation", *ptr; 6 ptr = strstr(str1, str2); 7 printf("The substring is: %sn", ptr); 8 return 0; 9 }
1 #include <stdio.h> 2 #include <stdlib.h> 3 int main(void) 4 { 5 char input[80], *endptr; 6 double value; 7 printf("Enter a floating point number:"); 8 gets(input); 9 value = strtod(input, &endptr); 10 printf("The string is %s the number is %lfn", input, value); 11 return 0; 12 }
#include <string.h> #include <stdio.h> int main(void) { char input[16] = "abc,d"; char *p; /* strtok places a NULL terminator in front of the token, if found */ p = strtok(input, ","); if (p) printf("%sn", p); /* A second call to strtok using a NULL as the first parameter returns a pointer to the character following the token */ p = strtok(NULL, ","); if (p) printf("%sn", p); return 0; }
#include <stdlib.h> #include <stdio.h> int main(void) { char *string = "87654321", *endptr; long lnumber; /* strtol converts string to long integer */ lnumber = strtol(string, &endptr, 10); printf("string = %s long = %ldn", string, lnumber); return 0; }
1 #include <stdio.h> 2 #include <string.h> 3 int main(void) 4 { 5 char *string = "abcdefghijklmnopqrstuvwxyz", *ptr; 6 /* converts string to upper case characters */ 7 ptr =strupr(string); 8 printf("%sn", ptr); 9 return 0; 10 }
#include <stdlib.h> #include <stdio.h> #include <string.h> char source[15] = "rFna koBlrna d"; char target[15]; int main(void) { swab(source, target, strlen(source)); printf("This is target: %sn", target); return 0; }
1 // isalpha.c 2 #include <syslib.h> 3 #include <ctype.h> 4 #include <stdio.h> 5 int main() 6 { 7 int c; 8 clrscr(); // clear screen 9 printf("Press a key"); 10 for(;;) 11 { 12 c=getchar(); 13 clrscr(); 14 printf("%c: %s letter",c,isalpha(c)?"is":"not"); 15 } 16 return 0; // just to avoid warnings by compiler 17 }
标签:enter get tin code clu des 空间 war cal
原文地址:https://www.cnblogs.com/very-beginning/p/12001006.html