View Code of Problem 58

#include<stdio.h>
int main()
{ 
  char str[100];
  gets(str);
 int i=0,count=0,flag;
 fiag=4;
   while(str[i]!='\0')
  {
    if(str[i]==' ')
      {
	  flag=2;}
      
  else if(flag==2)
	  {
	  count++;
      flag=3;}
     
	  i++;
  
  }
 printf("%d\n",count);
 return 0;
}
/*
Main.c: In function 'main':
Main.c:5:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   gets(str);
   ^
Main.c:7:2: error: 'fiag' undeclared (first use in this function)
  fiag=4;
  ^
Main.c:7:2: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 58