sahajjain01

Initialize a string and output it to a file.

Jul 20th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. //Program which initializes a string variable and outputs the string to the disk file.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<fstream.h>
  5. void main()
  6. {
  7.     clrscr();
  8.     char a[]="Program which initializes a string variable and outputs the string to the disk file.";
  9.  
  10.     ofstream ofile("disk.txt");
  11.     ofile<<a;
  12.     ofile.close();
  13.  
  14.     char b;
  15.     ifstream ifile("disk.txt");
  16.     while(!ifile.eof())
  17.     {
  18.         ifile.get(b);
  19.         cout<<b;
  20.     }
  21.     getch();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment