Hi there I am taking an intro c++ class and need some help loading data into arrays. I wouldn't have any problem loading rows into arrays but I need to load columns and have no idea how to do that. Thanks in advance for your help!
If 154 is the number of lines in the input file then each line contains several fields. And where are you going to store these fields?
Or each array denotes one field in a line?
Sorry for the confusion. Each array represents one field in each line. So each line has 12 elements. One country and the amount spent by that country for the last 11 years. I have 154 countries. Does that make sense?
At least it would be better to define one two-dimensional array
For example
double values[154][11];
You should use function std::getline that to read each field of a line and then convert and store numerical values in corresponding elements of the array.
I thought about using a multi-dimensional array but our teacher says she only wants us to use one-dimensional arrays. I suppose I will just use a 2D array anyway. Thanks for your help!