Advertisement
sahajjain01

Create file containg upper-case letters from another file.

Jul 23rd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. //Program that reads a file first.txt and creates a new file second.txt containing all words from file first.txt which start with an upper-case alphabet.
  2. /*first.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<ctype.h>
  14. void main()
  15. {
  16.     clrscr();
  17.  
  18.     char a[80];
  19.     ifstream ifile("first.txt");
  20.  
  21.     ofstream ofile("second.txt");
  22.  
  23.     while(!ifile.eof())
  24.     {
  25.         ifile>>a;
  26.         if(isupper(a[0]))
  27.         ofile<<a;
  28.     }
  29.     char b;
  30.     ifstream ifile2;
  31.     ifile2.open("second.txt");
  32.     while(!ifile2.eof())
  33.     {
  34.         ifile2.get(b);
  35.         cout<<b;
  36.     }
  37.     getch();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement