Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. int main()
  5. {
  6. using namespace std;
  7. string filename;
  8. cout<<"Enter name for new file:";
  9. cin>>filename;
  10. ofstream fout(filename.c_str());
  11. fout<<"For your eyes only!n";
  12. cout<<"Enter you secret number";
  13. float secret;
  14. cin>>secret;
  15. fout<<"Your secret number is"<<secret<<endl;
  16. fout.close();
  17. ifstream fin(filename.c_str());
  18. cout<<"Here are the contents of"<<filename<<":n";
  19. char ch;
  20. while(fin.get(ch))
  21. cout<<ch;
  22. cout<<"Donen";
  23. fin.close();
  24. cin.get();
  25. cin.get();
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement