I'm attempting to read a column of data from a .csv file into my C++ console application. Ideally I would like it input into an array (arr[n]) so I can manipulate the data, but it appears the commonly used getline() function only reads the values to an array (str).
I currently have:
int _tmain(int argc, _TCHAR* argv[])
{
// Ask user for filename
char filename[100];
cout << "Please specify the file name";
cin.getline(filename, 100);
ifstream file1;
file1.open(filename);'
// Read .csv file
string str;
int n = 0;
float arr[10000] = { 0 };
while (file1.good()) {
getline(file1, str);
n += 1;
//arr[n] = ??;
}
Is there anyway I can fill an array from the .csv file.
Thanks a lot