reading a .TXT and store

I am new at C++ and am having problems reading a .txt file into an array. My .txt file looks like this.
# Alphabet
{0,1, a,b,f}
# Number of states
14
# Initial states
1 0
# Final States
2 0 5
# Description
15
0 0 1
0 0 6
0 0 10
0 1 1
0 1 7
1 0 4
1 1 0
1 1 1
2 0 0
2 0 2
3 0 6
3 0 11
3 1 1
4 0 14
4 1 3

the alphabet, numberof states, initial states, final states, #39, should be kept separate, for example:
string alphabet = 0,1,a,b,f
NS=14
IS= 1,0
FS= 2,0,5
t=15
matriz=[[0,0,1],[0,0,6],...,[4,1,3]]

i am using fstream. this is my code:

#include <iostream>
#include <fstream>
# include <vector>
using namespace std;

int main ()
{
string alphabet,Is,Fs,aux;
int NS,Tr;
vector<string> line(2000);
string linee;
ifstream archivo;
archivo.open ("automaton.txt");
int i=0;
while (!archivo.eof())
{
getline (archivo,linee);
line[i] = linee;
i=i+1;
}
archivo.close();
int atoi(string);
alphabet =line[1];
aux=line[3];
NS=atoi(aux);
Is=line[5];
Fs=line[7];
aux=line[9];
Tr=atoi(aux);
}


Last edited on
Topic archived. No new replies allowed.