how to tranfer data from .csv to a double dimensional array in c++

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main ()
{
ifstream inFile;
inFile.open("C:/Users/Saad/Desktop/book2.csv");
int arr[8][5];
int c,i=0,j=0,k=0;
while(i>8){
while(j>2){
inFile >> c;
arr[i][j]=c;
j++;
}
i++;
}
i=0,j=0;
while(i>8){
while(j>2){
cout<< arr[i][j] <<endl;
j++;
}
i++;
}
return 0;
}

Data in CSV file:

1 2
2 16
3 2
4 5
5 2
6 7
7 9
8 7

please provide solution...
thanks!
Please, edit your post to enclose the code in code tags and be systematic about indentation. See http://www.cplusplus.com/articles/jEywvCM9/

Your program (if it wouldn't have logical errors) does attempt to read 40 values (5*8). Your example data contains only 16 values (2*8). How should your program handle that situation?
Topic archived. No new replies allowed.