This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Newbie questions about variables
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Andre Kirchner <sieg1974 at yahoo dot com>, gcc-help at gcc dot gnu dot org
- Date: Fri, 26 Sep 2003 15:06:07 -0500
- Subject: 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