首页 > 海船船员
题目内容 (请给出正确答案)
[主观题]

. void Test(void) { char *str = (char *) malloc(100); strcpy(str, “hello”);

. void Test(void) { char *str = (char *) malloc(100); strcpy(str, “hello”); free(str); if(str != NULL) { strcpy(str, “world”); printf(str); } } 请问运行Test 函数会有什么样的结果?

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“. void Test(void) { char *str …”相关的问题
第1题
试题4: void GetMemory(char *p ){ p = (char *) malloc(100 );} void Test(void ) { char *

试题4:

void GetMemory(char *p )

{

p = (char *) malloc(100 );

}

void Test(void )

{

char *str = NULL;

GetMemory(str );

strcpy(str, "hello world" );

printf(str );

}

点击查看答案
第2题
试题5:char *GetMemory(void ){char p[] = "hello world";return p;}void Test(void ){char *s

试题5:

char *GetMemory(void )

{

char p[] = "hello world";

return p;

}

void Test(void )

{

char *str = NULL;

str = GetMemory();

printf(str );

}

点击查看答案
第3题
阅读下列代码public class Test 2005{public static void main(String args[]){ System.out.prin

阅读下列代码 public class Test 2005{ public static void main(String args[]){ System.out.println((3>2)?4:5); } } 其运行结果是

A.2

B.3

C.4

D.5

点击查看答案
第4题
阅读下面程序class Test implements Runnable{public static void main(String[] args){Tes

阅读下面程序

class Test implements Runnable{

public static void main(String[] args){

Test t = new Test();

t.start();

}

public void run(){ }

}

下列关于上述程序的叙述正确的是

A) 程序不能通过编译,因为 start() 方法在 Test 类中没有定义

B) 程序编译通过,但运行时出错,提示 start() 方法没有定义

C) 程序不能通过编译,因为 run() 方法没有定义方法体

D) 程序编译通过,且运行正常

点击查看答案
第5题
下列代码的执行结果是()。public class Test{ public static void main(String args[]) {int a=4,

下列代码的执行结果是()。 public class Test { public static void main(String args[]) { int a=4,b=6,c=8; String s="abc"; System.out.println(a+b+s+c); System.out.println(); } }

A.ababcc

B.464688

C.46abc8

D.10abc8

点击查看答案
第6题
下列程序test类中的变量e的最后结果为()。public class test{ public static void main (String a

下列程序test类中的变量e的最后结果为()。 public class test { public static void main (String args[]) { int a=10; int b; int c; if(a>50) { b=9; } c=b+a; } }

A.10

B.0

C.19

D.编译出错

点击查看答案
第7题
考虑函数原型void test(int a,int b=7,char z=‘*’),下面的函数调用中,属于不合法调用的是()。

A.test(5);

B.test(5,8);

C.test(6,’#’);

D.test(0,0,’x’);

点击查看答案
第8题
下列代码的输出结果是()。class parent { void printme() {System.out.println("parent"); } }cl

下列代码的输出结果是()。

class parent

{

void printme()

{

System.out.println("parent");

}

}

class child extends parent

{

void printme()

{

System. out.println("child");

}

void printall()

{

super, printme();

this.printme();

printme();

}

}

public class test

{

public static void main(String args[])

{

child myc=new child();

myc.printall();

}

}

A.import java.awt.*;

B.import java.applet.applet;

C.import java.io.*;

D.import java, awt.graphics;

点击查看答案
第9题
在oneMethod()方法运行正常的情况下,程序段将输出什么? public void test(){ try { oneMe

在oneMethod()方法运行正常的情况下,程序段将输出什么? public void test(){ try { oneMethod(); System.out.println("condition 1"); } catch (ArrayIndexOutOfBoundsException e){ System.out.println("condition 2"); } catch(Exception e){ System.out.println("condition 3"); } finally { System.out.pritln("finally"); } }

A.condition 1

B.condition 2

C.condition 3

D.condition 1

点击查看答案
第10题
若有如下程序: #include"stdio.h" void main() {FILE *fp; fp=fopen("test","wb"); fprintf(fp,"%d%.1f,%c%c",5,238.41,'B','h'); fclose(fp); } 则程序运行后向文件输出的结果是()。

A.5238.41Bh

B.5238.4,Bh

C.5,238.4,B,h

D.5238.41Bh

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