Input file with string and intinto int array

was wondering how you would put integers from an input file that contains strings into an array.
The input file format is
Exam1:000
Exam:000
If you only need the integer, but not the string, you might do
1
2
    fin.ignore(50,':');
    fin >> n;

where fin is the name of the input stream and n is an integer. Assuming the length of the string is less than 50 characters.

To read all the values from the file that way
1
2
3
4
    while ( fin.ignore(50,':') && fin >> n )
    {
        array[count++] = n;
    }

Topic archived. No new replies allowed.