Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. void check() {
  9.  
  10. string text;
  11. ifstream file;
  12. file.open("test.txt");
  13. getline(file, text);
  14.  
  15. if (text == "") {
  16. cout << "There's no data in file" << endl;
  17. }
  18. else {
  19. cout << "File contains:" << endl;
  20. cout << text << endl;
  21. }
  22. }
  23.  
  24.  
  25. void masokslur() {
  26.  
  27. std::ofstream outfile;
  28. string a = "kuy nambah yuk";
  29. string text;
  30.  
  31. getline(cin, text);
  32. outfile.open("test.txt", std::ios_base::app);//std::ios_base::app
  33. outfile << "\n"+text+"\n";
  34. //getline(cin, text);
  35. //cin >> text;
  36. //outfile << text;
  37. //return 0;
  38. }
  39.  
  40. int main() {
  41.  
  42. check();
  43. std::ofstream outfile;
  44. std::ifstream asolololo;
  45. string text;
  46. ofstream file;
  47.  
  48. asolololo.open("test.txt");
  49. //file.open("test.txt");
  50. //masokslur();
  51. cout << "Type some text" << endl;
  52. ////getline(cin, text);
  53. //file << text;
  54.  
  55. masokslur();
  56. //outfile.open("test.txt", std::ios_base::app);
  57. //outfile << "" + text;
  58.  
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement