cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
how to tranfer data from .csv to a doubl
how to tranfer data from .csv to a double dimensional array in c++
Aug 4, 2015 at 9:30am UTC
mohdadnan111
(8)
#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!
Aug 4, 2015 at 12:38pm UTC
keskiverto
(10402)
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.