c - Printing the value of a 0-initialized array element prints nothing, why? -


i have initialize char array 0's. did like

char array[256] = {0}; 

i wanted check if worked tried testing it

#include <stdio.h>  int main() {     char s[256] = {0};     printf("%c\n", s[10]);     return 0; } 

after compile , run it, command line output shows nothing.

what missing ? perhaps initialized array in wrong manner ?

tl;dr -- %c character representation. use %d see decimal 0 value.

related , c11, chapter §7.21.6.1, (emphasis mine)

c          if no l length modifier present, int argument converted unsigned char, and resulting character written.

fyi, see list of printable values.

that said, hosted environment, int main() should int main(void), @ least conform standard.


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -