Hi I am new here and i need help for my assignment. I want to read data from a file. I've used getline but it wont read the first line inside the file, can someone help me please? Here is my code:
void test(std::ifstream& infile, string& a, string& b, string& c)
{
infile >> a;
infile >> b;
infile >> c;
}
int main()
{
ifstream file_("Level1.txt");
string line;
string a, b, c;
while (getline(file_, line))
{
test(file_, a, b, c);
}
cout << a << " " << b << " " << c;
return 0;
}
in my file:
aa
bb
cc
but output:
bb cc