Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void initialise_books()
- {
- cout << "????";
- ifstream inFile;
- inFile.open("Users.txt");
- if (inFile.fail())
- {
- cerr << "Error Opening File" << endl;
- exit(1);
- }
- string file_contents;
- string line;
- while (getline(inFile, line))
- {
- file_contents += line;
- file_contents.push_back('\n');
- }
- cout << file_contents;
- /*string line;
- fstream file(filename.c_str());
- while (getline(file, line))
- {
- std::stringstream linestream(line);
- std::string value;
- while (getline(linestream, value, ','))
- {
- std::cout << "Value(" << value << ")\n";
- }
- std::cout << "Line Finished" << std::endl;
- }
- */
- }
- int main()
- {
- Book book1(1, "LSD psychotherapy", "Grof", 1);
- initialise_books();
- string filename;
- /*cout << "Name your file> ";
- getline(cin, filename);
- fstream file(filename.c_str());
- if (!file)
- {
- cout << "I could not open the file.\n";
- return EXIT_FAILURE;
- }
- else
- {
- string line;
- int count = 10;
- while ((count > 0) && getline(file, line))
- {
- cout << line << '\n';
- count--;
- }
- file.close();
- }
- */
- /*ofstream outFile;
- outFile.open("Users.txt", ios_base::app);
- outFile << endl << "dodalem linijke" ;
- outFile.close();
- ifstream inFile;
- inFile.open("Users.txt");
- if (inFile.fail())
- {
- cerr << "Error Opening File" << endl;
- exit(1);
- }
- string file_contents;
- string line;
- while (getline(inFile, line))
- {
- file_contents += line;
- file_contents.push_back('\n');
- }
- cout << file_contents;*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement