[Solved] C++: Trying to read from a file line by line, saving into a vector and then printing the vector prints nothing
[ad_1] You could – after skipping the line count – read in each individual character and compare it to ‘0’ or ‘1’. See the following code: int main() { vector<bool> bits; ifstream f(DATAFILE); if (f.is_open()) { int dummy; f >> dummy; char c; while (f >> c) { if (c == ‘1’) { bits.push_back(true); } … Read more