Page 1 of 1

data type

Posted: Tue Apr 11, 2006 6:50 am
by Roby
what's the difference between these functions:

Code: Select all

char * something( char * a ) // first function
{
 ...
}

char [] something( char a [] ) // second function
{
 ...
}
Someone said to me that the second function is more safety to use than the first function? Is that true? If it's true, where's the danger? Thanx in advance...

Posted: Wed Apr 12, 2006 10:31 am
by mf
The second declaration is invalid -- you can't use "char[]" as a return type.

However, an argument of type 'char *' is the same thing as 'char[]', because in C/C++ arrays are passed as a pointer.