#include<stdio.h>
#include<string.h>
int main()
{
int sta=1;
char Tobefound[][20]={"as","bss","csss","dssss"},s[10];
int len=sizeof(Tobefound)/sizeof(Tobefound[0]); //计算二维字符数组的元素个数!
gets(s);
for(int i=0;i<len;i++)
if(strcmp(s,Tobefound[i])==0){ //字符串比较不能用"=="!
printf("There it is:%s!!!!",s);
sta=0;
break;
}
if(sta) printf("Not found!!!");
return 0;
}
查找特定字符串元素
于 2023-03-31 21:57:19 首次发布