How can I remove the extra character which gets taken in when i read the file:
2 3 4 1 6 87 33 9 22 11
Output:2 3 4 1 6 87 33 9 22 11 '\n'
int main() {
ifstream ifs("input.txt");
vector<int> data;
double val;
while (ifs >> val)
{
data.push_back(val);
cin.ignore('\n');
}
for (int i = 0; i < data.size(); i++)
cout << data[i] <<" ";
system("pause");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire