The following is part of client program for a fraction class. I wrote the class and now am testing it with the given client program. When I try to run it, I get this error:
Assertion
'in'failed.
Code:
bool eof(ifstream& in);
cout << "\n----- Now reading Fractions from file\n";
ifstream in("fraction.data");
assert(in);
while (!eof(in)) {
Fraction f;
if (in.peek() == '#') {
in.ignore(128, '\n'); //skip this line, it's a comment
} else {
in >> f;
cout << "Read fraction = " << f << endl;
}
As a relative beginner to C++, I don’t really understand what this part of the code is supposed to be doing:
ifstream in("fraction.data");
assert(in);
And when I try to debug and I get to that point, it says:
No source available for
"__kernel_vsyscall() at 0x12e416"
So yeah, in conclusion I’m pretty clueless about why this happening 😛
EDIT: Here are the include statements
#include <iostream>
#include "fraction.h"
#include <fstream>
#include <cassert>
using namespace std;
So I finally got it. I just need to move my “fraction.data” file to main project directory. Before, I had it in the source folder within the directory.