首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; int main() { int*p; *p=9: cout
有如下程序: #include using namespace std; int main() { int*p; *p=9: cout
admin
2019-05-06
20
问题
有如下程序:
#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
解析
此题考查的是指针的使用。本题中,在给*p赋值前,指针p并没有指向一个具体的对象。此时可以通过编译,但运行时由于p中为随机值,该赋值可能会破坏内存中某个重要的地址空间的内容,导致程序出错。
转载请注明原文地址:https://kaotiyun.com/show/dOAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类的定义。横线处的语句是()。classMyClass{public:MyClass(inta=0,intb=0){X=a;Y=b;}voidChange()co
派生类的成员函数不能访问基类的
在算法的4个特性中,算法必须能在执行有限个步骤之后终止指的是算法的______特性。
下面的描述中,正确的是()。
下列叙述中正确的是()。
C++中每个类都有一个隐含的______指针。
数据库管理员(DBA)是数据库系统的一个重要组成部分,有很多职责。以下选项不属于DBA职责的是()
A、 B、 C、 D、 C面向对象中的多态性是指当多种事物继承自一种事物时,同一种操作在它们之间表现出不同的行为:而封装性是指将数据和算法捆绑成一个整体,这个整体就是对象,描述对象的数据被封装在其内部。c++
按照“先进后出”原则组织数据的数据结构是()。
下面数据结构中,属于非线性的是()。
随机试题
平推流的特征是()。
试述大型企业应树立的战略思想。
经脱羧基后可作为精胺、精脒生成原料的氨基酸是
宗族是指()。
SMA面层施工不得使用的机械为()。
任何单位都必须经公安交通管理部门和()的批准,才能按规定占用和挖掘城市道路。
武仲兴
三位股评专家正在对三家上市公司明天的股价走势进行预测。甲说:“公司一的股价会有一些上升,但不能期望过高。”乙说:“公司二的股价可能下跌,除非公司一的股价上升超过5%。”丙说:“如果公司二的股价上升,公司三的股价也会上升。”三位股评专家果然厉害,一天
结构化程序所要求的基本结构不包括()。
Nowthe______portcitynearthemouthofthemightyYangtzeRiverishopingtoleaveitsrecordofturmoilbehindandrenewits
最新回复
(
0
)