data type

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
Roby
Experienced poster
Posts: 101
Joined: Wed May 04, 2005 4:33 pm
Location: Tangerang, Banten, Indonesia
Contact:

data type

Post 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...
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post 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.
Post Reply

Return to “C”