Coder's Guild Mailing List

RE: Memory Writing Problem

Posted by Buettner, Charles on 1999-05-02

Kory you could also do using the assert macro.

#include <assert.h>

char *Buffer;
Buffer = new char[100];
assert ( Buffer != 0 ); // This tests to verify that the memory is
allocated, if not 
            // the program will terminate.
// do something with Buffer
delete [] Buffer;       // You also need to delete all your
allocated space from free
            // space.

I hope this helps.

DarkCrystal



> 16bit DOS with borland c++ 4.52, if it matters which compiler I have.  
> Anyway.  I just allocate memory like this:
> 
> char *Buffer;
> 
> Buffer = new char [100];
> //...do something with buffer;
> delete Buffer;
> 
> I can't explain it.  Do I need to change my memory model?  It's on large.
> I 
> not sure..Thanks tho.
> 
> Kory
>