1、在碰到#…#…#提取中间…的时候,若使用
datestr = strtok(datestr, &s);
while( datestr != NULL )
{
p[t] = datestr;
t++;
datestr = strtok(NULL, &s);
}
来分离·,当…为空的时候会被自动舍弃,因此要用如下方法
void *data;
char *p,*p1,strs[9][30];
uint8_t i=0,t=0;
p = strchr(data, '#');
while(i<9)
{
p1=strchr(p+1,'#');
for(t=0;t<p1-p-1;t++)
{
strs[i][t]=*(p+1+t);
}
strs[i][t]='\0';
p=p1;
}
2、判断两个字符串是否相同要用strcmp()函数,函数返回0为相同,不能直接用==判断。
本文介绍如何在含有特殊字符('#')的字符串中准确提取子串,并探讨了使用strtok和指针操作进行分割的方法。同时,强调了使用strcmp函数进行字符串比较的重要性。

3923

被折叠的 条评论
为什么被折叠?



