#include#include int main(){ char str = "a =3,b=4,c=-1,d*e=12"; char key[4] = {0}; char value[4] = {0}; const char *split = ","; char *p; p = strtok(str,split); while(p!=NULL){ //printf("p=%s",p); sscanf(p,"%[^=]=%s",key,value); printf("key=%s\n",key); printf("value=%s\n",value); p=strtok(NULL,split); } return 0;}
分析, =两边的为key和value