there is a question puzzles me.In the code below msg and quote are both char array.why sizeof(msg) and sizeof(quote) gave me different result?
Code:
#include <stdio.h>
void fortune_cookie(char msg[])
{
printf("Message reads: %s\n",msg);
printf("msg occupies %i bytes\n",sizeof(msg));
}
int main()
{
char quote[] = "Cookies make you fat";
printf("quote occupies %i bytes\n",sizeof(quote));
fortune_cookie(quote);
return 0;
}
Result:
quote occupies 21 bytes
Message reads: Cookies make you fat
msg occupies 8 bytes