Skip to content

Instantly share code, notes, and snippets.

@FernandoBasso
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoBasso/8918338 to your computer and use it in GitHub Desktop.
Save FernandoBasso/8918338 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void say_msg(char msg[]);
int main(void) {
char str[] = "C is a butt-kicking programming language.\n";
say_msg(str);
printf("%ld\n", sizeof(str)); // 43. WTF?!
printf("%ld\n", sizeof(&str)); // 8 or 4. Why? Isn't str already a pointer variable.
// Why the need for the & operator?
return 0;
}
void say_msg(char msg[]) {
printf("%ld\n", sizeof(msg)); // 8 or 4. Makes sense.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment