#333 problem with fopen at winxp?

WSL
closed
nobody
None
invalid
User_Error
2013-01-30
2003-04-06
No

this program should write 100000 bytes:

#include <stdio.h>

int main(int argc, char *argv[])
{

char bytes_w[100000];

FILE *f = fopen("testfile", "w+");

fwrite(bytes_w, 100000, sizeof(char), f);

fflush(f);
fclose(f);

return 0;
}

but it writes 100007 (I am not joking).

this bug occurs only on winxp.

keep up the good job!

Discussion

  • Laszlo Agocs
    Laszlo Agocs
    2003-04-06

    Logged In: YES
    user_id=342636

    You should use "w+b" instead of "w+".
    (it's 100007 bytes because \n is converted to \r\n in text
    mode)

     
    • status: open --> wont-fix
     
    • milestone: 102882 --> 102880
    • priority: 5 --> 1
    • assigned_to: earnie --> nobody
    • summary: streams problem at winxp --> problem with fopen at winxp?
    • status: wont-fix --> closed-accepted
     
    • milestone: 102880 -->
     
  • Earnie Boyd
    Earnie Boyd
    2013-01-30

    • labels: MinGW -->
    • status: closed-accepted --> closed
    • resolution: --> invalid
    • category: --> User_Error
    • milestone: --> WSL