I think I'm having an issue with my use/understanding of vectors in C++. Any advice would be greatly appreciated!
I'm trying to use a vector of vectors of floats to store data coming from an input file. I know that, at most, a line of floats will have 14 elements. So far I've coded:
stringstream convert;
for(int i = 0; i < 14; i++)
numbers.push_back(0);
...
while(getline(is,line))
{
...
for(int i = 0; i < 14; i++)
numbers[i] = 0;
convert << line;
for(int i = 0; i < 14; i++)
convert >> numbers[i];
if(numbers[13] == 0) //This if statement checks to see if there were any missing fields, and an error message prints to
//an output file if that is the case.
}
So my issue is that the output file holds an error for every single line, leading me to believe there's a problem with my assignment statements. I'm not too familiar with C++ vectors, is there something different I should be doing?
The entire program is pretty involved, so I just posted the part I think is suspect here. If anyone wants to see the whole think let me know.