strchr函数
返回第一次出现字符c的地址,要用指针去接收
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>int main(){char str[100] = "123456789@";char* pos = strchr(str, '@');if (pos == NULL){printf("没有查找到@符号");}else {printf("查到了@符号,在字符串中的位置:%d\n", pos-str);}//取出qq号码//方式1:char qqNum[64] = {0 };sscanf(str, "%[^@]", qqNum);printf("QQ号码:%s\n", qqNum);//方式2:int qqPosition = pos-str;for (int i = 0; i < qqPosition; i++){printf("%c", str[i]);}return 0;}