Counting number of occurrences of a char in a string in C June 13, 2023 by Tarik Here’s the way I’d do it (minimal number of variables needed): for (i=0; s[i]; s[i]=='.' ? i++ : *s++);