有如下程序: #include using namespace std; int main() { int*p; *p=9; cout

admin2013-09-11  3

问题 有如下程序:
    #include
    using namespace std;
    int main()
    {
    int*p;
    *p=9;
    cout<<”The value at p:”<<*p;
    return 0:
    }
编译运行程序将出现的情况是(    )。

选项 A、编译时出现语法错误,不能生成可执行文件
B、运行时一定输出:The value at p:9
C、运行时一定输出:The value at P:*9
D、运行时有可能出错

答案D

解析 题目程序中“int*p;”是定义了一个指针变量p,“*p=9;”是将p当前指向的指针赋为9。指针p在执行这个赋值操作前并没有初始化这个变量p,所以会有p未初始化的警告错误。
转载请注明原文地址:https://kaotiyun.com/show/VzBD777K
0

随机试题
最新回复(0)