Space Count C Program Example

How to write a c program to space count in c programming ?

Solution:
#include <stdio.h>

int main()
{
char str[100];
int i, count = 0;

gets(str);

for(i = 0; str[i] != '\0'; i++)
if(str[i] == ' ')
count++;

printf("%d\n", count);

return 0;
}


Learn More :