Friday, 6 September 2013

How to write a C++ program to erase text file when number of lines is > 30

How to write a C++ program to erase text file when number of lines is > 30

This program prints something to text file. I want to erase the content of
text file when number of lines exceeds 30 then again it should start to
print inside text file.
void GPSCallback(const gps_common::GPSFix::ConstPtr& msg)
{
std::ofstream output;
output.open("file1.txt",std::ios_base::app);
output<<"\n"<<msg->latitude<<","<<msg->longitude;
output.close();
usleep(10000000);
}

No comments:

Post a Comment