Subject: Re: Lesson in C / mktemp
To: seebs@plethora.net, Patrick Welche <prlw1@cam.ac.uk>
From: Andrew Brown <twofsonet@graffiti.com>
List: netbsd-help
Date: 09/27/1998 20:10:05
>>Just out of curiosity, can someone explain to me why I had to do this:
>> char *foo="rfbXXXXXX";
>
>String literals are not modifiable.
that is to say...the char array "rfbXXXXXX" gets put in a read-only
segment of your program's image. mktemp attempts to modify it.
char foo[]="ffbXXXXXX";
would do what you want. that makes an array in a read/write segment.
>>And from another list... What is the difference between int **val and
>>int (*val)[] ?
>
>Get the comp.lang.c FAQ and start working your way up. You might want
>to look for a program called 'cdecl'.
the first is declaration of an array of pointers to integers, so the
compiler needs to know the size of the array at compile-time, and
&val == &val[0]
is true. the second is a declaration of a pointer to a pointer to an
integer, so all the compiler allocates at compile-time is space for a
pointer, and
&val != &val[0]
since the right hand side dereferences the pointer.
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
warfare@graffiti.com * "information is power -- share the wealth."