指针与数组区别

来源:互联网 发布:内八字 知乎 编辑:程序博客网 时间:2024/06/03 17:59

 下面两段程序的输出结果

1.

  char *buf1="hello";
  char *buf2="hello";
  if(buf1==buf2)
    cout<<"equal"<<endl;
  else
    cout<<"unequal"<<endl;

2.

  char buf1[10]="hello";
   char buf2[10]="hello";
   if(buf1==buf2)
    cout<<"equal"<<endl;
   else
    cout<<"unequal"<<endl;

答案:输出分别为equal  unequal.
原创粉丝点击