#include <stdio.h> #include <string.h>
#include <stdio.h> #include <string.h> //#define NULL (void *)0 int main(void) { char s1[] = "hello world itcast"; char key = 'o'; char *p, *q; q = s1; while ((p = strchr(q, key)) != NULL) { printf("%p\n", p); printf("%s\n", p); q = p+1; } return 0; }
此函数没有在dest数组里默认加'\0',需要手动自己加。注意。
#include <stdio.h>
#include <string.h>
//#define NULL (void *)0
int main(void)
{
char s1[] = "hello world itcast";
char key = 'o';
char *p, *q;
q = s1;
while ((p = strchr(q, key)) != NULL) {
printf("%p\n", p);
printf("%s\n", p);
q = p+1;
}
return 0;
}
strncpy 范围 strch
最新推荐文章于 2023-11-15 10:55:51 发布