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
void fortune_cookie(char msg[])is the same asvoid fortune_cookie(char* msg), so you get sizeof(char*), your result is 8 which means you're using 64-bit machine, right?