I need to read data from a text file, store the char and int in separate variables, then print it to the screen. The data file can be of any length, but it will follow this format.
Example data file:
t 34
! 56
9
The bit I'm struggling with, is I need to store the whitespace character if there is one.
My first instinct was to do this:
while(infile >> letter >> num){
cout << letter << " " << num << "\n";
}
However, the loop stops once it hits that whitespace. Should I use a getline()? If so, how can I format that to two separate variables?