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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -