fprintf to a network file

Discussion in 'C++' started by wf_798088, Jul 7, 2010.

  1. wf_798088

    wf_798088 New Member

    Joined:
    Jul 7, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    on windows 2008 server,when I use fprintf to write a LAN network share file frequently,sometimes the file pointer jump back:

    fp = fopen(filename,"a+");

    ...

    while()
    {

    ...
    pos1 = ftell(fp); <====== pos1 == 1000
    fprintf(fp,"%s\n",str);
    pos2 = ftell(fp); <====== pos2 == 800
    ...

    fflush(fp);
    }


    At the same time, the file contents will be disordered.
    The latter record will overrite the previous record.



    please help to explain it, thanks.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice