.
.
Last edited by Tibo; 03-28-2003 at 02:47 AM.
Both are valid, assuming you've allocated memory for the pointer (char*). The array is basically a pointer pointing to some statically allocated memory.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
C doesn't check array bounds. So if you just declare as char * or in array fashion like char str[3] that will not do if the string to be copied is of different size.
So best way is to declare a character pointer. Like char * str;
and then allocate memory for it using malloc() function.
But be sure to allocate memory for one more character alongwith number of characters desired to accomodate the null character.