- 论坛徽章:
- 0
|
一个关于字符串处理的问题
char *strchr(const char *s, int c);
DESCRIPTION:
The strchr() function returns a pointer to the first
occurrence of the character c in the string s.
返回一个指针,指向字符c在字符串s中第一次出现的位置
如果有一个字符串 "abcd=efgh",指针是char *myStr;
可以声明char *x, char *y 和char *z. 然后x=myStr;y=strchr(myStr, '=');z=y+1;*y='\0';
这样呢,x和z就分别是你想要得字符串了
netdemon教我的
不知道楼主是不是这个意思
你再看:
*****************************************************
char * strchr(const char * s, int c)
{
for(; *s != (char) c; ++s)
if (*s == '\0')
return NULL;
return (char *) s;
}
************************************************
以上是string.c中strchr的源代码,实际上也是一个一个比较找出来的 |
|