void 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;
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中用‘,’分割的字符串