Reading data from a text file into variables and arrays

Hi, I'm trying to read a text file and store the data into some variables and arrays.
Here is an example of the data:

param T := 3 ;
param alpha :=
1 1
2 1
3 1
;
param r :=
1 15
2 15
3 18
4 15
5 12
6 14
7 11
8 18
9 14
10 20
;

What I need to do is to store the number 3 into my T integer, store ones into my alpha[3] array, and store the numers in the second column of r in my r[10] array.

I know I need the following:
1
2
3
4
  	ofstream myfile;
	myfile.open("Data\1.dat", ios::out);
        //What should go here?
	myfile.close();


How can I parse the file so that I ignore the unneeded text (like "param T:="), and store only the needed text (like "3")? Thanks.
You can load the file into a stringstream for easier manipulation. Also, you could check every read character, whether its in the range of 0 to 9.

Aceix.
Topic archived. No new replies allowed.