字符数组定义

#include <stdio.h>

typedef unsigned char u;

int main()
{
 u8 a[] = {'0x51', '0x52', '0x53', '0x55','\0'};    //这种写法,后面要加'\0'  ,否则 sizeof(a) = 4,  printf溢出
 int n = sizeof(a);            //5
 printf("n = %d\n",n);     //1235
 printf("%s\n",a);
}

/*
int main()
{
 char a[]="abcd";
 printf("%d\n",sizeof(a));     //5
 printf("%s\n",a);
}*/

你可能感兴趣的:(字符数组定义)