niusouti.com

设有结构体类型定义: struct try { int one; float two; }*str;若要动态开辟一个结构单元,使指针str指向其首地址,正确的语句是______。A.str=(try*)malloc(sizeof(try));B.*str=(struct try*)malloc(sizeof(struct try));C.str=(strucy try*)malloc(sizeof(struct try));D.str=(struc try)malloc(sizeof(struct try

题目

设有结构体类型定义: struct try { int one; float two; }*str;若要动态开辟一个结构单元,使指针str指向其首地址,正确的语句是______。

A.str=(try*)malloc(sizeof(try));

B.*str=(struct try*)malloc(sizeof(struct try));

C.str=(strucy try*)malloc(sizeof(struct try));

D.str=(struc try)malloc(sizeof(struct try));


相似考题
参考答案和解析
正确答案:C
解析:由于在ANSIC中malloc函数返回的地址为void,故在调用函数时,必须利用强制类型转换将其转换成所需的类型。
更多“设有结构体类型定义:struct try{int one; float two;}*str;若要动态开辟一个结构单元,使指针str ”相关问题
  • 第1题:

    下列选项中可以获取Python整数类型帮助的是()。

    A.help(int)

    B.dir(int)

    C.help(float)

    D.dir(str)


    help(int)

  • 第2题:

    下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    C.循环执行1次

  • 第3题:

    1、下列程序的执行结果为?x = 10 print type(x) x = 10.0 print type(x) x = '10.0' print type(x)

    A.<type 'int'> <type 'float'> <type 'str'>#B.<type 'int'> <type 'int'> <type 'int'>#C.<type 'str'> <type 'str'> <type 'str'>#D.程序出错
    A

  • 第4题:

    00330038003000301585067361821下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    A

  • 第5题:

    3. 结构体指针变量的一般定义形式如下: struct 结构体类型名 *结构体指针变量名;


    正确