Hi,
I'm using c++ (2011) with the truncate function. I would like to cut the file fichier.txt after the byte 1000.
So here is my programm
I would like to use the truncate function.
Here is the program
And here is the fileCode:using namespace std;
#include <string>
#include <fstream>
#include <stdio.h>
#include <unistd.h>
// namespace std;
// {
// include <string>
// }
int main()
{
///// creation d'un fichier random avec des a aux bits Ã* supprimer
/// marche pas
fstream lulu;
lulu.open("C:/Users/H2O/Desktop/odoo_exe/fichier.txt",ios::out);
for (int i=1;i<900;i=i+1)
{
lulu << "bonjour le monde"<<i<<"\n";
}
truncate ("C:/Users/H2O/Desktop/odoo_exe/fichier.txt",10000);
lulu.close();
return 0;
}
bonjour le monde 1
...../ like that
bonjour le monde478
bonjour le monde479
bonjour le monde480
bonjour le monde481
// the file should stop here but it starts again
bonjour
bonjour le monde890
bonjour le monde891
bonjour le monde892
bonjour le monde893
bonjour le monde894
bonjour le monde895
bonjour le monde896
bonjour le monde897
bonjour le monde898
bonjour le monde899
So i don't understand what is going on
thank you