C
Chad
Given the following code
include <stdio.h>
#include <stdlib.h>
int main(void) {
char *msg_list[] = {" apple", " orange", " grape" };
printf("name: %s \n", msg_list[0]);
printf("size: %d \n", sizeof(msg_list));
return 0;
}
I thought taking sizeof(msg_list) would give me the size of the string
"apple" (ie 6). Instead, I get
the following:
name: apple
size: 12
What I'm missing here?
Chad
include <stdio.h>
#include <stdlib.h>
int main(void) {
char *msg_list[] = {" apple", " orange", " grape" };
printf("name: %s \n", msg_list[0]);
printf("size: %d \n", sizeof(msg_list));
return 0;
}
I thought taking sizeof(msg_list) would give me the size of the string
"apple" (ie 6). Instead, I get
the following:
name: apple
size: 12
What I'm missing here?
Chad