CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: fprintf...

  1. #1
    Join Date
    Dec 2001
    Location
    New York
    Posts
    529

    fprintf...

    hi i have a function called
    Code:
    writetofile(const char* filename)
    {
      FILE *stream;
      stream = fopen(filename,"a+");
       fprintf( stream,"%s",strptr); // printing the orginal string 
       fprintf(stream," ");
      fclose(stream);
    }
    when I call the function first time, i got no proglem.. but when i calll next time, I got run time error.... why is that?
    BP

  2. #2
    Join Date
    Aug 2002
    Location
    VA, USA
    Posts
    137
    BeePo,

    Where is the error occurring? Can you pin-point the line
    of code in your debugger? I would pay special attention
    to the fopen return file pointer and the "strptr" pointer.
    Make sure niether are null and the "strptr" is properly
    null terminated and not already deallocated. You could
    also save yourself a line of code by combining the two
    fprintf statements into one. Just put the space of the
    string conversion specifier.

    Regards, willchop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured