Alex Rivera | Logout

Why is fwrite writing more than I tell it to?

Asked 2009-10-19T00:15:07.637
20
FILE *out=fopen64("text.txt","w+");
unsigned int write;
char *outbuf=new char[write];
//fill outbuf
printf("%i\n",ftello64(out));
fwrite(outbuf,sizeof(char),write,out);
printf("%i\n",write);
printf("%i\n",ftello64(out));

output:

0
25755
25868

what is going on? write is set to 25755, and I tell fwrite to write that many bytes to a file, which is at the beginning, and then im at a position besides 25755?

Edit
Report

1 Answer

0

Interesting. Works fine on Windows VC++, albeit ftello64 replaced with ftell.

answered 2009-10-19T00:28:22.557

Your Answer