View Code of Problem 58

#include <stdio.h>
#include <string.h>

int main(){
	
	char str[128];
	gets(str);
	
	int words=0;
	int i,length;
	length = strlen(str);
	for(i=0;i<length;i++){
		if((str[i]!=' ')&&(str[i+1]==' ')){
			words++;	
		}
	}
	printf("%d",words);
	
	return 0;
}

Double click to view unformatted code.


Back to problem 58