wincc 环境下c语言处理字符串分割的strtok函数
来源:岁月联盟
时间:2012-08-16
CTxtDemDlg::GetAddressAndUnit(char* str,char *Add,char *Unit,char *Name)
{
char*p;
char p1=',';
p=strtok(str,&p1);
strncpy(Add,str,strlen(p));
int i=0;www.2cto.com
while(p!=NULL)
{
p=strtok(NULL,",");
i++;
if(i==1 && p!=NULL)
{
strncpy(Name,p,strlen(p));
}
else if(i==3 && p!=NULL)
{
strncpy(Unit,p,strlen(p));
break;
}
else if(p==0)
{
break;
}
}
}
使用strtok函数在字符串str中用‘,’分割的字符串
上一篇:[面试]字符串专题
下一篇:c指针与地址 指针与函数