字符数组定义

  • Post author:
  • Post category:其他


#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);

}*/



版权声明:本文为u011068464原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。