Hi! I paste a short sample for a subfunction of a class of mine. I get an error about the declaration of "of" and I'm not quite sure what's wrong :rolleyes: To this I would like to ask if anybody knows how can I check in a new file for an empty line? because I want this function to open a file, search for an empty line in a text file and add a line before the empty line, so the empty line is preserved as a guide for opening the same file when needed again to add more information.


Truck 1:
City1 - City2: 50km
// <- My guiding empty line here
City2 - City3: 40km

In this way if I want to add info for a truck I just have to reach an empty line and to add some statistics before it.

Thanks in advance!

Here is the code:

int Truck_Manager::Truck::tmp_save(Truck T, short n) { // Not complete
    ofstream of("tmp_save.txt", ios::app);
    of.write((char *) km_passed, sizeof(unsigned));

And this is the error:
Route_Manager.cpp: In member function `int Truck_Manager::Truck::tmp_save(Truck_Manager::Truck, short int)':
Route_Manager.cpp:92: error: variable `std::ofstream of' has initializer but incomplete type

<< moderator edit: disabled smilies >>

If I aint completly wrong you need to include fstream.