On Saturday, 25 August 2012 15:46:50 UTC+2, Bill Cunningham wrote:
[regarding "array" is not a pointer"]
This is something I know because its been drilled into me. But
the thing is I haven't yet caught onto the real meaning yet. For
example I know of a funtion whose prototype is char * but if you put
a string into it the function doesn't work correctly it's called
cbc_crypt(). You have to pass char key[]="string"; to char *key, the
first parameter. Not quite sure why yet but that's the way it works.
That's a really nice example; (warning) I didn't know about
cbc_crypt()
until just now, but I will try to explain it anyway. My man page
says:
int cbc_crypt(char *key, char *data, unsigned datalen,
unsigned mode, char *ivec);
Notice it is `char *`, not `const char *`. This is a hint that the
function will be read, and *write* into the buffer. So one way or
another, `key` must point to writeable memory.