All pastes #963069 Raw Edit

Anonymous

public text v1 · immutable
#963069 ·published 2008-03-30 05:49 UTC
rendered paste body
#include <stdio.h>

int main()
{
	char string[100];
	char ch;
	int word,x;

	printf("Enter a string\nString: ");
	fgets(string,sizeof(string),stdin);
	printf("%s",string);

	for(x = 0; string[x] != '\0'; x++)
	{
		ch = string[x];
		if(ch == 32)
		{
			word++;
		}

	}
	word += 1;
	printf("String has %d words",word);
	return 0;
}