怎么用c语言判断一个字符串里是否由某个字符呢?
例如char email={"123456@}里是否有‘@’呢?#include<stdio.h> int main() { char email[]={"123456@"}; char *p=email; while (*p) { if (*p=='@') { printf("YES\n"); break; } p++; } if (*p=='\0') printf("No\n"); return 0; }
#include<stdio.h> int main() { char x; char a[14]="123456@"; printf("输入查询字符:"); scanf("%c",&x); for(int i=0;a[i]!='\0';i++) { if(a[i]==x) { printf("找到字符%c\n",a[i]); } } return 0; }