The short answer is that you can't just assign an array.
edit: the longer answer is that to copy "this is a test" into a char array, you have to copy each char individually into an element of the array.
When you try to assign "this is a test" to test2darray, you are actually trying to store a pointer to the string literal "this is a test" into the memory location (test2darray + 30) which you have already declared as type char.
To clarify further:
the array test2darray is just a contiguous region of 30000 bytes of memory which you have declared will hold 30000 chars. test2darray is the same as (test2darray+30) -- it's the address of the beginning of the second 30-char chunk of those 30000 bytes. Since you told the compiler you will store chars there, it won't let you store a pointer there. (Well, not without some trickery, anyway.)
strcpy works because it actually copies char by char from the source string into the destination array.
This post has been edited by r.stiltskin: 17 March 2011 - 03:09 PM
Yes, it's true for all arrays. But strcpy is only for char arrays.
No, it's not the only way to assign values to an array -- you could for example write a loop to copy element by element from source to destination. And there are other functions with similar functionality, like strncpy, memcpy, memmove, strcat, strncat all of which do some sort of copying of data from one area to another.
In general, for arrays of types other than char, you write a loop in which you copy element by element from the source to the destination, although you can also use memcpy.
This post has been edited by r.stiltskin: 17 March 2011 - 03:31 PM