[LCP] Question on setfub

Ludwig Isaac Lim ludz_lim at yahoo.com
Fri Jul 20 02:36:28 UTC 2007


Hi:
Hi:


   Supposing I have the following functions:

void  write_helper  (FILE  *fp)
{
    /* write stuff to fp */
    fwrite(....,fp);

}


void  main_writer()
{
     FILE *fp;
     char buff [MY_BUFF_SIZE];

     fp = fopen("somefile","w");
     setbuf(fp,  buff);     /* allocate buffer for fp */

     fwrite(....,fp);   /* write to buffer */
     fwrite(....,fp);
     ...
     write_helper(fp);
  
     fclose(fp);
}


  Is the buffer declared in main_writer() visible in
write_helper()? I mean, will the fwrite() in fp writes to
same buffer in main_writer()?  Is the above code ok?

   Many thamks!

ludwig lim




       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  



More information about the linuxCprogramming mailing list