arrays - C memory allocations -
i wondering how c compiler allocated memory character array initialize yourself, instance:
char example[] = "an example string";
if single character 8 byte
, example 17 bytes
or have more because needs \0
to finish off?
or overestimate how memory needs?
this code:
#include <stdio.h> int main(void) { char example[] = "an example string"; printf("%zu", sizeof(example)); }
compiled with:
gcc -std=c99 -o proof proof.c
returns:
18 (bytes, not bits)
because of \0
character @ end of string
Comments
Post a Comment