c++ - The difference between 0 and '0' in array -
i have question array initialization
what difference between
char a[6]={0};
and
char a[6]={'0','0','0','0','0','0'};
how compiler interpret above 2 expression? same or not??
'0'
ascii character number 0. value 48.
the constant 0
zero byte or null byte, written '\0'
.
these 4 equivalent:
char a[6] = {0}; char a[6] = {0, 0, 0, 0, 0, 0}; char a[6] = {'\0', '\0', '\0', '\0', '\0', '\0'}; char a[6] = "\0\0\0\0\0"; // sixth null byte added automatically compiler
Comments
Post a Comment