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

Threaded View

  1. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: ofstream writing replaces entire file with 0s

    Quote Originally Posted by fiodis View Post
    The code runs without crashing,
    Code:
            char bytesToWrite[2];
    //...
            delete[] bytesToWrite;
    This does not "run fine". You are calling delete[] on a pointer that was never initialized with new[]. Once that illegal line is executed, the behaviour of the program becomes undefined.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; January 3rd, 2013 at 06:04 PM.

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