problem with truncate

I would like to truncate a file and to remove the end of the file
in this scoop i use truncate

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"<<i<<"\n";
}
truncate ("C:/Users/H2O/Desktop/odoo_exe/fichier.txt",1000);
lulu.close();

return 0;
Hello Guil,


PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

Along with the proper indenting it makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.


It is also best to post the whole program.

Since you failed to mention it, what operating system are you using?

Initial research looks like the "truncate()" function is for "Unix" type systems. It does not look like "Windows" has this function. Of course I could be wrong, I have not had the chance to dig very far.

I will do some more research, but you may have to go about this in a different way.

Andy
Topic archived. No new replies allowed.