Quote:
Originally Posted by aspire1
#include <string.h>
char *strcpy( char *s1, const char *s2)
*copies the string s2 into the character array s1. The value of s1 is returned.
|
While that seems to solve
j0hnsmiths problem, it still leaves him with the essential question unanswered.
In one place, he has declared an array of 100 char's, and called it 'test'. We are allowed to use the shorthand notation of referring to the address of the zeroth element of the array by simply using the variable name (the ultimate cause of this confusion). Nevertheless, the array is still 100 char's.
Later in the code,
j0hnsmith tries to make an assignment to the array of 100 chars called test. In the assignment, he says 'make the address of the zeroth element of the 100 char's equal to the address of the literal string "fails"'. Since this cannot happen, the compiler bails.
This shorthand use of arrays by name probably causes more confusion than any other issue in the C language. It is a convenience to those who understand it, but a tripping point to those who do not.
--- rod