Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. void initialise_books()
  2. {
  3. cout << "????";
  4. ifstream inFile;
  5. inFile.open("Users.txt");
  6. if (inFile.fail())
  7. {
  8. cerr << "Error Opening File" << endl;
  9. exit(1);
  10. }
  11. string file_contents;
  12. string line;
  13. while (getline(inFile, line))
  14. {
  15. file_contents += line;
  16. file_contents.push_back('\n');
  17. }
  18. cout << file_contents;
  19.  
  20.  
  21. /*string line;
  22. fstream file(filename.c_str());
  23. while (getline(file, line))
  24. {
  25. std::stringstream linestream(line);
  26. std::string value;
  27.  
  28. while (getline(linestream, value, ','))
  29. {
  30. std::cout << "Value(" << value << ")\n";
  31. }
  32. std::cout << "Line Finished" << std::endl;
  33.  
  34. }
  35.  
  36. */
  37.  
  38. }
  39.  
  40.  
  41.  
  42.  
  43. int main()
  44. {
  45.  
  46. Book book1(1, "LSD psychotherapy", "Grof", 1);
  47. initialise_books();
  48. string filename;
  49. /*cout << "Name your file> ";
  50. getline(cin, filename);
  51. fstream file(filename.c_str());
  52. if (!file)
  53. {
  54. cout << "I could not open the file.\n";
  55. return EXIT_FAILURE;
  56. }
  57. else
  58. {
  59. string line;
  60. int count = 10;
  61. while ((count > 0) && getline(file, line))
  62. {
  63. cout << line << '\n';
  64. count--;
  65. }
  66. file.close();
  67. }
  68.  
  69. */
  70.  
  71.  
  72.  
  73.  
  74. /*ofstream outFile;
  75. outFile.open("Users.txt", ios_base::app);
  76. outFile << endl << "dodalem linijke" ;
  77. outFile.close();
  78.  
  79.  
  80. ifstream inFile;
  81. inFile.open("Users.txt");
  82. if (inFile.fail())
  83. {
  84. cerr << "Error Opening File" << endl;
  85. exit(1);
  86. }
  87. string file_contents;
  88. string line;
  89. while (getline(inFile, line))
  90. {
  91. file_contents += line;
  92. file_contents.push_back('\n');
  93. }
  94. cout << file_contents;*/
  95.  
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement