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

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -