头文件 #include <string.h>
#include <stdio.h>
#include <string.h>
int main()
{
char str[]="I suppose i am very happy.";
char * first_a = strchr(str,'a');
char * last_a = strrchr(str,'a');
printf("original:%s\n",str);
printf("str1:%s\n",first_a);
printf("str2:%s\n",last_a);
return 0;
}
输出:
original:I suppose i am very happy.
str1:am very happy.
str2:appy.
Program ended with exit code: 0