strchr与strstr函数有什么区别?

2025-04-28 07:26:26
推荐回答(1个)
回答1:

原型:extern char *strchr(char *s,char c);

用法:#include

功能:查找字符串s中首次出现字符c的位置

说明:返回首次出现c的位置的指针,如果s中不存在c则返回NULL。

举例:

// strchr.c

#include
#include

main()
{
char *s="Golden Global View";
char *p;

clrscr();

strchr(s,'V');
if(p)
printf("%s",p);
else
printf("Not Found!");

getchar();
return 0;
}