Thread: no eyedea?

  1. #1
    jumbo mumbo
    Guest

    no eyedea?

    i was reading the data from a file and am stuck.the problem is that i have to read the following input file:

    ALPHABET:
    a, b ;
    VARIABLES:
    S, A, B ;


    but my code can read only input like:

    ALPHABET: a, b;
    VARIABLES: S, A, B ;

    and my code is somewhat like:


    while(!dfa1File.eof())
    {
    dfa1File.getline(temp,200,':');
    strcpy(temp2,"ALPHABET");
    if (strcmp(temp,temp2)==0)
    {
    dfa1File.getline(temp,200,'\n');
    int i=0;
    char* token;
    int buffer[200];
    token = strtok( temp, ":,\n.");
    while( token != NULL )
    {
    buffer[i]=i;
    token = strtok( NULL, ":,\n."); i++;
    }

    alphabets= new int[i];

    for(int j=0;j<i;j++)
    {
    alphabets[j]=buffer[j];
    }

    numAlphabets=i;
    }

    strcpy(temp2,"STATES");
    if (strcmp(temp,temp2)==0)
    {
    dfa1File.getline(temp,200,'\n');
    int i=0;
    char* token;
    int buffer[200];
    token = strtok( temp, ":,\n.");
    while( token != NULL )
    {
    buffer[i]=i;
    token = strtok( NULL, ":,\n."); i++;
    }
    states= new int[i];
    for(int j=0;j<i;j++)
    {
    states[j]=buffer[j];
    }
    numStates=i;
    }


    ne eyedeas?

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Use Code Tags please.

Popular pages Recent additions subscribe to a feed