Hi I want to insert new info at a specific line in a file. But I want to also delete the previous info on that line. However I've only been able to put in the new info not overwrite the previous. How can I easily accomplish this?
Code:
#include <iostream> // for std::cout
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
fstream dataflow;
int i =0;
int value=19;
string item;
dataflow.open("print.txt", ios::in | ios::out);
for (i=0;i<10;i++)
{
dataflow << i << std::endl;
}
dataflow.seekp(0, ios::beg);
dataflow << value;
cout << value << endl;
return 0;
}