S calculated parameter referred to the number of words contained in the string, the function returns a value

#include <stdio.h> 
#include <string.h> 
int Fun (char * S) 
{ 
	int COUNT = 0; 
	int In Flag = 0; // declaration flag 
	the while (! * S = '\ 0') 
	{ 
		IF ( ! * S = '' && flag == 0) 
		{ 
			COUNT ++; 
			flag =. 1; 
		} 
		if (S == * '') when the string appears // spaces, the flag is set to 0, the first if statement can be entered , the number of those words. 1 
			In Flag = 0; 
		S ++; 
	} 
	return COUNT; 
} 
void main () 
{ 
	char S [81]; 
	the printf ( "Please INPUT A String:"); 
	the gets (S); 
	the printf ( "of The String have have D Word% \ n-", Fun (S)); 
}

  

Guess you like

Origin www.cnblogs.com/-slz-2/p/11260292.html