首页 > 考试题库
题目内容 (请给出正确答案)
[主观题]

下面的代码有什么问题?void DoSomeThing(...){char* p;...p = malloc(1024); // 分配1K的空间i

下面的代码有什么问题?

void DoSomeThing(...)

{

char* p;

...

p = malloc(1024); // 分配1K的空间

if (NULL == p)

return;

...

p = realloc(p, 2048); // 空间不够,重新分配到2K

if (NULL == p)

return;

...

}

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“下面的代码有什么问题?void DoSomeThing(..…”相关的问题
第1题
下面的代码有什么问题?并请给出正确的写法。

点击查看答案
第2题
下面的代码有什么问题?class A{public:A() { p=this; }~A() { if(p!=NULL) { delete p; p=NUL

下面的代码有什么问题?

class A

{

public:

A() { p=this; }

~A() { if(p!=NULL) { delete p; p=NULL; } }

A* p;

};

点击查看答案
第3题
以下代码有什么问题?struct Test{Test(int ) {}Test() {}void fun() {}};void main(void ){

以下代码有什么问题?

struct Test

{

Test(int ) {}

Test() {}

void fun() {}

};

void main(void )

{

Test a(1);

a.fun();

Test b();

53

b.fun();

}

点击查看答案
第4题
下面代码有什么问题?Void test3(char* str1){char string[10];if(strlen(str1)<=10){strcp

下面代码有什么问题?

Void test3(char* str1)

{

char string[10];

if(strlen(str1)<=10)

{

strcpy(string, str1);

}

}

点击查看答案
第5题
下面代码有什么问题?Void test2(){char string[10], str1[10];for(i=0; i<10;i++){str1[i]

下面代码有什么问题?

Void test2()

{

char string[10], str1[10];

for(i=0; i<10;i++)

{

str1[i] ='a';

}

strcpy(string, str1);

}

点击查看答案
第6题
下面的代码中有什么错误吗?_______ using System; class A { public virtual void F(){ Conso

下面的代码中有什么错误吗?_______

using System;

class A

{

public virtual void F(){

Console.WriteLine("A.F");

}

}

abstract class B:A

{

public abstract override void F();

点击查看答案
第7题
下面的代码中有什么错误吗?_______ using System; class A { public virtual void F(){

下面的代码中有什么错误吗?_______

using System;

class A

{

public virtual void F(){

Console.WriteLine("A.F");

}

}

abstract class B:A

{

public abstract override void F();

}

点击查看答案
第8题
12 . 下面的代码输出是什么,为什么? void foo(void) { unsigned int a = 6; int b = -20; (a+b

12 . 下面的代码输出是什么,为什么?

void foo(void)

{ unsigned int a = 6;

int b = -20;

(a+b > 6) puts("> 6") : puts("<= 6");

}

点击查看答案
第9题
12 . 下面的代码输出是什么,为什么?void foo(void){unsigned int a = 6;int b = -20;(a+b > 6

12 . 下面的代码输出是什么,为什么?

void foo(void)

{

unsigned int a = 6;

int b = -20;

(a+b > 6) puts("> 6") : puts("<= 6");

}

点击查看答案
第10题
给定下面的代码片段:public void Test() {try {method();System.out.println("Hello Wor
给定下面的代码片段:

public void Test() {

try {

method();

System.out.println("Hello World");

}

catch (ArrayIndexOutOfBoundsException e)

{

System.out.println("Exception?");

}

catch(Exception e)

{

System.out.println("Exception1");

}

finally{

System.out.println("Thank you!");

}

}

如果函数method正常运行并返回,会显示下面的哪些信息?()

A.Hello World

B.Exception

C.Exception1

D.Thank you!

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改