|
From: Ioannis V. <no...@ho...> - 2002-07-30 08:46:40
|
sizeof() reports the total size of the array when it is used in the
scope of its definition.
When you use an array as an argument of a function in reality it is not
an array but a pointer.
consider the following example:
void makea(char array[100])
{
while(*array)
*array++='a';
}
int main()
{
char somearray[500];
for(unsigned long i=0; i<sizeof(somearray)-2; i++)
somearray[i]='s';
somearray[sizeof(somearray)-1]='\0';
makea(somearray);
}
void makea(char array[100]) is equivallent to void makea(char *array)
and void makea(char array[])
So sizeof(array) when applied inside the makea() is equivallent to
sizeof(char *).
array there is char *array.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|