reading 2 integers from a file and then characters

I'm having one devil of a time with an easy concept :(.

See, I've got a text file like this: (sample data)

5 6
A B C D E
A B
B C
C D

I want to save both integers in variables and then move on to read in the characters like so:

1
2
3
4
5
6
7
8
9
10
11
ifstream file.open("test.txt");
char element;

int number1 = file.get();
int number2 = file.get();

while( !file.eof() )
{ 
file >> element;
vector.push_back(element);
...


See what I'm trying to do? Get the 2 numbers and then move on to snag the chars.
I've tried reading them all into a char vector and then casting the first 2 elements (0 & 1) as integers but that didn't work (despite casting in either C or C++ style--bad idea, sure, but i was experimenting).

Is there some simple syntax I'm missing out on?

EDIT: typo in my code
Last edited on
Just use
file >> number1

, etc.
Topic archived. No new replies allowed.