sizeof 另类

来源:互联网 发布:stm8烧写软件 编辑:程序博客网 时间:2024/04/28 12:44


 static char *strings[] ={
  "this is string one",
  "this is string two",
  "this is string three",
 };
 const int string_no = ( sizeof strings ) / ( sizeof strings[0] );

sizeof strings =12 ?????

 sizeof strings[0]=4 ?????

 string_no =3 ??? 


 char *strings1XXXX[] ={
  "thisisstringone",
  "thisisstring two",
  "this is stringthree",
 };
 int test =sizeof (strings1XXXX);  //12
  int string_no1 = (test ) / ( sizeof (strings1XXXX[0]) );  //3

看到这明白了,int test =sizeof (strings1XXXX); 实际把它看成是三个字符串指针来处理的!!!


shit !






0 0
原创粉丝点击