sizeof()'s strange behviour



sizeof() operator gives 2 different types of size outputs :\ but I do not
understand why:


#include <stdio.h>
#include <stdlib.h>


int my_size( char [] );


int main()
{
char s[] = "Saurabh Nirkhey";

printf("sizeof(%s): %d\n", s, sizeof(s));
printf("sizeof(%s): %d\n", s, my_size(s));


return 0;
}



int my_size( char s[] )
{
return sizeof(s);
}


============ OUTPUT =============
/home/arnuld/programs/C $ gcc -ansi -pedantic -Wall -Wextra 5-4.c
/home/arnuld/programs/C $ ./a.out
sizeof(Saurabh Nirkhey): 16
sizeof(Saurabh Nirkhey): 4
/home/arnuld/programs/C $


--http://lispmachine.wordpress.com/

Please remove capital 'V's when you reply to me via e-mail.

.



Relevant Pages