1 #include <io_utils.h> 2 #include <string.h> 3 4 int main() { 5 char *string = "Hello World!"; 6 char *result = strchr(string, 'l'); 7 char *result_reverse = strrchr(string, 'l'); 8 puts(result); 9 puts(result_reverse); 10 11 char *substring_position = strstr(string,"Wor"); 12 puts(substring_position); 13 PRINT_INT(substring_position - string); 14 15 16 char *string2 = "C, 1972; C++, 1983; Java, 1995; Rust, 2010; Kotlin, 2011"; 17 char *break_set = ",;"; 18 19 int count = 0; 20 char *p = string2; 21 22 do { 23 p = strpbrk(p, break_set); 24 if (p) { 25 puts(p); 26 p++; 27 count++; 28 } 29 } while (p); 30 31 PRINTLNF("Found %d characters.", count); 32 return 0; 33 }View Code
标签:子串,substring,string,puts,count,C语言,char,查找,result From: https://www.cnblogs.com/liumy/p/17112629.html