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 \0to 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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -