I am trying to make an integer vector by extracting integers from the text file. In the file, there are 10 numbers separated by a comma.
1,2,3,4,5,6,7,8,9,10
Like this.And my code is below
int main()
{
ifstream read;
read.open("input.txt");
vector<int> arr;
if (read)
{
int value;
while (read >> value)
{
arr.push_back(value);
}
}
read.close();
return 0;
}
It compiles at least, but I don't know why it shows just wrong results