Subfuction to read a csv file into 2d double array

I am so lost. I've finished the other 90% of my assignment, but I am stuck.
I have a csv file and I have to use it to fill a double 2d array. I know that I first have to make it into a string and then convert the string to an array(I was given the function for that). What I have so far obviously doesn't work. But the problem is that I can't use libraries like sstream, fstream, etc. Only string and cstdlib (and iostream).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void csvReader(double num[][2], string filename){

ifstream mydata("Values.csv");

mydata.open();

if (mydata.is_open()) {

while (getline(mydata, filename, ',')){

}

strToDouble(filename);  // a function that will convert from string to double

for (unsigned int i = 0; i<filename.length();i++){

filename[i]=num[i][2];

}

mydata.close();

}

else cerr << "Could not open file";

}


I also have to do the opposite, where I take an array and insert the values into a csv but I didn't even know where to start.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

void csvWriter(double data[][2], string filename, int SIZE){

ofstream mydata("Values_Output.csv");

mydata.open();

if (mydata.is_open()) {

for (int i = 0; i<SIZE;i++){

mydata << data[i][2] <',';

}

mydata.close();

}

else cerr << "Could not open file";

}
Topic archived. No new replies allowed.