Jack said:
> The code is below:
>
> char *p;
> p = (char*)malloc(10 * sizeof(char)); //LINE1
Better: p = malloc(10 * sizeof *p);
> After LINE1, the 10 char-length memory that p points to is empty or
> some random characters?
The values of the ten bytes, starting with the byte pointed to by p, are
indeterminate. That means you can't rely on their having meaningful values.
I am reluctant to accede to the use of the word "random", in case it gives
you the idea that you can get entropy from those bytes. You certainly can't
do that reliably.
The safe, portable assumption to make is that you must not /read/ from those
bytes unless you have first /written/ values to them.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)