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
Post a Comment