c - Divided a string by one of a few options -


i have char array in loop, divided math operations ,

for example, right looking = sign , so

   (char *p = strtok(data,"="); p != null; p = strtok(null, " "))     {         numberofchars++;     } 

i loop not "=" token , 1 of these : +,-,*,\,=

so increment in loop numberofchars every 1 of these.

so : a = b + c 3 .

you can symply loop through string

for (size_t i=0; < strlen(data); i++)     {         if ((data[i] == '+') ||              (data[i] == '-') ||              (data[i] == '*') ||              (data[i] == '\') ||              (data[i] == '='))         {             numberofchars++;         }     } 

Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -