This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie questions about variables


Hi Andre,

You cannot strcpy into an array of 256 pointers.  Did you mean
  char theString[256];
?

theLine variable is being overwritten each time.

The memory occupied by theString variable is not erased from the computer's memory -- it is returned to the OS's free store.  If you are worried about the data stored in that variable, especially "post mortem" of the program's execution, you may want to take measures to overwrite the variable with garbage.

Assuming such a level of paranoia is warranted.

To allocate an object from the heap in C, use malloc.  And use free to relinquish it back to the heap.

To allocate an object from the free storein C++, use new. And use delete to relinquish it back to the free store.

HTH,
--Eljay



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]