5.2 C语言作业

1.

data  || 1(<<7)

data && ~(1<<7)

data ^  (1<<7)

2.

(1)5

(2)6,5,5

d=5,循环执行5此,就是5个char类型,strlen=5

3.

tmpInfo1.height=1;

tmpInfo1.baseInfo.with=2

tmpInfo2.height=1

tmpInfo2->baseInfo.with=2

tmpInfo3->height=1

4.9

5.

(1)int *p=(int *)0x80000000;

*p=tmp;

tmp=*p;

(2)char *q=(char*)&tmp;

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

buf[4+i]=q[i];

(3)

char*buf[count]===>char *buf=(char*)malloc(count*sizeof(char))

6.

(1)seqn[tail]=data;

tail++;

(2)data=seqn[head];

head++;

(3)if(head==tail)

(4)if((tail-head)==SEQLEN)

(5)head=tail;

tail++;

(6)tail-head;

(7)SEQLEN

7.

(1)Rdy[i] || (1<<i)

(2)Rdy[j] && ~(1<<j)

(3)

8.可能出现i>=100等情况,数组不包含该下标。并且*value=0没有意义。

加一个0<=i<100,把*value=0移到赋值语句前面

9.int型变量作为参数,调用了参数为int型变量的函数,会导致数据出错。

10.(1)str指针指向NULL,给空指针申请了10字节的内存空间,之后又进行了12字节空间的赋值。

(2)

第三行:p=(char*)malloc(32);

void Test(void)

{

        char a[32]="hello world";

        char *str;

        GetMemory(str);

        strcpy(str,a);

        printf(str);

        free(str);

        str=NULL;

}        

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值