关于memset返回值 [英] regarding memset return value
本文介绍了关于memset返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int i;
memset(Deviceptr, 0 * 00 , sizeof (Deviceptr))
i = Deviceptr [ 0 ];
然后
i =?
回复我的答案并解释如何
解决方案
请注意:
- 您的代码无法编译。
- 您是忽略
memset
返回值。- 您没有向我们显示
Deviceptr $的声明c $ c>变量。
ifDeviceptr
是一个整数数组然后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.
ifDeviceptr
is an array of integers theni
value should be0
.
[update: fixedC
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屋!
查看全文