Sunday, July 12, 2009

I need a program in c++ that read an archive?

The archive is like this: avemaria { anormal } . Ok I need that the program separate the word "anormal" and put it in a queue.


This is what I got:


#include%26lt;iostream%26gt;


#include%26lt;fstream%26gt;


#include%26lt;cassert%26gt;


#include%26lt;string%26gt;


using namespace std;





int main()


{


ifstream archivo;


string reading,


palabras;





getline(cin, palabras);


archivo.open(palabras.data());


assert( archivo.is_open() );





for (;;)


{


archivo %26gt;%26gt; reading;





if ( archivo.eof() ) break;


if ( reading == "{")


cout%26lt;%26lt;reading;


cout%26lt;%26lt;" ";


}





system("pause");


}





Please, help me.


Thanks

I need a program in c++ that read an archive?
Read the string. When you get to the "{", read the following characters into the queue until you get to the "}". (It's called a state machine, and this one is trivially simple.)


No comments:

Post a Comment