I am trying to convert a .txt file to an array in c++. The problem is the text file contains:
a letter a number a letter a letter a letter a number
a letter a number a letter a letter a letter a number
I want to create a 2d array so that it will look like this
(a letter) (a number) (a letter a letter a letter) (a number)
(a letter) (a number) (a letter a letter a letter) (a number)
How can I let c++ ignore the spaces between the mid three letters and consider the spaces between the letter and the number only and what will be the type of array?
another option is that letters ARE numbers. if the numbers in the file are integers a simple array of integers will work, can a quick cast on the letter columns back to char if needed (say, to print them) would work fine.
int derp[] = {1234, 'x', 5678, 'j'};
cout << (char)(derp[1]) << endl; // writes the x letter out.
cout << derp[0]; //writes the 1234 number out.
and so on.
the standard >> operator on files will ignore whitespace.