数组和指针赋值时的误区

声明一个数组

      char test[10]

错误用法1

      test="fuzhi";

错误用法2

      test++

错误用法3

     Do(test);

      void Do(char *p)

     {

      p="fuzhi";

     }

可以下面用

 Do(test);

      void Do(char *p)

     {

       p[0]=‘f’;

       p[1]='z'

     }



test是一个数组常量,不能当做指针来用


猜你喜欢

转载自blog.csdn.net/wang371372/article/details/53421976