sahajjain01

Count no. of lines not starting with 'A' in a file.

Jul 22nd, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. //Program to count number of lines not starting with the alphabet 'A' in a text file.
  2. /*out.txt:-
  3. The C++ is a the general purpose the programmingthe language.
  4. An appple a day keeps the doctor away.
  5. History repeats itself.
  6. All that glitters is not gold.
  7. If life deals you lemons, make lemonade.
  8. */
  9.  
  10. #include<iostream.h>
  11. #include<conio.h>
  12. #include<fstream.h>
  13. #include<string.h>
  14. void main()
  15. {
  16.     clrscr();
  17.  
  18.     char a[80];
  19.     int count=0;
  20.     ifstream ifile("out.txt");
  21.     while(!ifile.eof())
  22.     {
  23.         ifile.getline(a,80);
  24.         if(a[0]!='A')
  25.         count++;
  26.     }
  27.     cout<<endl<<"Number of lines not starting with 'A' in the file out.txt: "<<count;
  28.     getch();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment