#include<fstream.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{ clrscr();
int count=0,wr=0;
char str[100];
char word[20];
ofstream obj;
obj.open("tanuj",ios::out); // for writing purpose
cout<<"Enter anything (100 word limit) ";
gets(str);
obj<<str;
obj.close();
ifstream abc;
abc.open("tanuj",ios::in); // for reading purpose
if(!abc)
{ cout<<"File not found";
exit(0);
}
cout<<"The content in it was ";
puts(str);
while(!abc.eof())
{ abc.getline(word,20,' ');
if(word[0]=='a'||word[0]=='A')
{ wr++;
count++;
}
else wr++;
}
cout<<"\n Total no. of words is "<<wr;
cout<<"\n Total no. of words starting with a or A is "<<count;
cout<<"\n Total no. of spaces is "<<wr-1;
abc.close();
getch();
}