c - Ignore Certain Strings -


i have c code reads in contents of html form stdin and, @ moment tokenizes string.

fgets(formip, 1024, stdin);  pch = strtok (formip,"=&"); while (pch != null) {     printf ("%s\n",pch);     pch = strtok (null, "=&");     printf ("<br>\n"); } 

this produces output this:

checkbox,checked,value,2 checkbox,checked,value,3 

does know how can expand not write "checkbox" or "value" strings?

you can use strcmp check if strings equal or not, important not skip next call strtok otherwise end in infinite loop:

while (pch != null  ) {     if( strcmp( pch, "value") != 0 && strcmp(pch, "checkbox") != 0)     {          printf ("%s\n",pch);        printf ("<br>\n");     }     pch = strtok (null, "=&"); } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -