0

I'm a beginer in C++, and I've read number of posts regarding reading CSV files but have not understood how to convert them in to an array

my file reads just numbers that are seperated by tabs
23 34 67 78
45 56 89 90
23 45 79 23
33 14 74 78
etc.

Could someone please tell me how to convert this file into a 2 dimentional Array ?

2
Contributors
3
Replies
10
Views
9 Years
Discussion Span
Last Post by Nick Evan
0

Post the code where you read the file, that makes life a lot easier.

But you'll have to do something like:

while (lines in file)
{
    while (words in line)
    {
           storage[line][word] = inputread;
           word++;
    }
    line++;
}
0

which object to use to seek if there are lines in the file and to check the words in line?

I know getline to obtain a whole line and eof to check end of the file but dont know how to pick up number from tab seperated file

0

You can also use Getline with a third parameter as delimiter to obtain words.
Here's an example that reads a file word by word seperated by comma's

string word;
ifstream infile("something.csv");
while (getline(infile, word, ','))
{      
   	cout << "Word: " << word << "\n";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.