侃侃无极
‘求字串’是什么意思?可以用库函数不?刚回错地方了,好像:求串长,strlen(str),连接strcat(s1,s2),求字串strstr(s1,s2)程序代码:int main(void){ char s1[] = "if you want someshing"; char s2[] = “please do something”; char substring[64]; int ret = 0; // 串长 printf("len of s1 is %d, len of s2 is %d.\n", sizeof(s1), sizeof(s2)); // 连接 printf("%s\n", strcat(s1,s2)); // 求子串 memset(substring, 0, sizeof(substring)); printf("please input a string for match\n"); scanf("%s\n", substring); ret = strstr(s1, substring); if (ret) printf("string %s matched in %s.\n", substring, s1); else printf("no such string %s.\n", substring); return -ret;}