0

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.

Ex.txt:

Truck 1:
City1 - City2: 50km
// <- My guiding empty line here
Truck2:
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("");
    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 >>

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by zyruz
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.