no eyedea?

This is a discussion on no eyedea? within the C++ Programming forums, part of the General Programming Boards category; i was reading the data from a file and am stuck.the problem is that i have to read the following ...

  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
    RoD
    RoD is offline
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21