Quote:
Originally Posted by trist007
Isn't 'buf' by itself a char pointer?
|
No, buf is declared as an array of char.
strerror() returns a char*; thus you should declare buf to be a char*. The area in memory that strerror() returns quite possibly is a statically declared buffer of N bytes. Thus the callee (that would be your program) should assign a pointer to that buffer. You cannot assign a char* to an array, although you can copy the string data using functions such as strcpy() or sprintf().
Anyhow, consider the following:
Code:
char array[30];
char* a = array;
Above, 'a' is pointing to the first byte (char) of the array. If you still have questions about the differences between pointers and arrays, I would suggest that you revisit your C reference book.