标题:关于数组和指针的疑问
取消只看楼主
苍翠的路
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2014-4-15
结帖率:100%
已结贴  问题点数:10 回复次数:0 
关于数组和指针的疑问
程序代码:
#include<iostream>

using namespace std;

int main()
{
    char *p = "OK";
    cout<< *p <<endl;                //O
    cout<< p <<endl;                //OK

    char ch[] = "OK";
    cout << *ch << endl;             //O
    cout << ch << endl;             //OK
    
    int q[] = {1,2,3};
    cout << *q << endl;              //1
    cout << q << endl;              //0012ff34(地址值)

        return 0;


为什么输出p、ch、q的结果是这样?
*p、*ch、*q的作用都是对首地址取引用?
还有,数组名到底是不是指针?
还请大家指教。
搜索更多相关主题的帖子: color 
2014-09-16 22:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-436175-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.155998 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved