关于memset返回值 [英] regarding memset return value

查看:914
本文介绍了关于memset返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  int  i; 
memset(Deviceptr, 0 * 00 sizeof (Deviceptr))
i = Deviceptr [ 0 ];





然后

 i =?



回复我的答案并解释如何

解决方案

请注意:

  • 您的代码无法编译。
  • 您是忽略 memset 返回值。
  • 您没有向我们显示 Deviceptr 变量。




if Deviceptr 是一个整数数组然后 i 值应为 0





[更新:固定 C 代码]

< pre lang =C> #include < < span class =code-leadattribute> stdio.h >
#include < memory.h >

#define Max_port 4

int main()
{
char Deviceptr [Max_port];
int i;
memset(Deviceptr, 0 sizeof (Deviceptr));
i = Deviceptr [ 0 ];
printf( i =%d \ n,i);
return 0 ;
}



[/ update]


int i;
memset(Deviceptr,0*00,sizeof(Deviceptr))
i=Deviceptr[0];



Then

i=?


reply me the answer and explain how

解决方案

Please note:
  • Your code won't compile.
  • You are ignoring memset return value.
  • You didn't show us the declaration of the Deviceptr variable.


if Deviceptr is an array of integers then i value should be 0.


[update: fixed C code]

#include <stdio.h>
#include <memory.h>

#define Max_port 4

int main()
{
    char Deviceptr[Max_port];
    int i;
    memset(Deviceptr,0,sizeof(Deviceptr));
    i=Deviceptr[0];
    printf("i = %d\n", i);
    return 0;
}


[/update]


这篇关于关于memset返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆