Can someone help me with understanding why this code isn't working, when program is running, "booklist.txt" can't be loaded.
When I call function listbooks while the program is running, it doesn't display anything on the screen, so that's the main problem. (file is not empty.)
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
void listbooks()
{
ifstream TheFile("booklist.txt");
char autor;
char bookname;
long int isbn;
while (TheFile >> autor >> bookname >> isbn)
{
cout << autor << " " << bookname << " " << isbn << endl;
}
}
int main()
{
int choice;
do {
cout << "1.List all books" << endl;
cout << "2.Borrow book" << endl;
cout << "3. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
listbooks;
break;
case 2:
break;
default:
cout << "";
}
} while (choice != 3);
system("pause");
return 0;
}