I made some code which gets the lines from the file. Yet it does not seem to be working properly.
Code:
vector<string> read_top_ten_from_txt (int board_size, int puzzle_number)
{
vector<string> top_ten;
string filename, line;
/* if file exists, read top 10 from it */
if (Checks_for_file("puzzle_3x3_001.txt"))
{
/* opening input file stream */
ifstream read_from_txt ("puzzle_3x3_001.txt");
for (int i = 0; i < board_size + 1; i++)
{
getline(read_from_txt, line);
}
while (true)
{
getline(read_from_txt, line);
if (line[0] == '\0')
{
break;
}
top_ten.push_back(line);
}
}
else
{
cout << "Error: Couldn't open file (" << "puzzle_3x3_001.txt" << ").";
}
return top_ten;
}
int main()
{
vector<string> vec = read_top_ten_from_txt(3,001);
for (int i = 0; i < vec.size(); i++)
{
cout << vec[i] <<endl;
}
}