Mega Code Archive
For loop a char array
#include
int main(void)
{
char str[80];
int i, spaces;
printf("Enter a string: ");
gets(str);
spaces = 0;
for( i = 0; str [ i ]; i++)
if(str[i]==' ')
spaces++;
printf("Number of spaces: %d", spaces);
return 0;
}