问题描述
以下实际上是模式匹配程序的一部分
i尝试过,memset没有用
-1
#include< string.h>
#include< stdio.h>
#include< stdlib.h>
int main(无效)
{
int maxpat [80];
memset(maxpat,-1,80);
for(i = 0; i< 80; i ++)
printf("%d \ t",maxpat [i]);
返回EXIT_SUCCESS;
}
但是我得到了o / p
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1
- 370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 - 370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
D:\ siju\lcc6 \ noisedisp.exe"
返回代码0
执行时间0.048秒
按任意键继续......
为什么会这样...... ????
Hi,
the following is actually a part of the pattern matching program which
i tried ,memset is not setting the entire integer array with
-1
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int maxpat[80];
memset(maxpat,-1,80);
for(i=0;i<80;i++)
printf("%d\t",maxpat[i]);
return EXIT_SUCCESS;
}
but i am getting o/p as
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
-370086 -370086 -370086 -370086 -370086 -370086 -370086 -370086
-370086 -370086
"D:\siju\lcc6\noisedisp.exe"
Return code 0
Execution time 0.048 seconds
Press any key to continue...
why is this so..????
推荐答案
抱歉,我忘了申报i,但o / p仍然相同
sorry I forgot to declare i, but still the o/p is same
您只设置数组的前80个字节,而不是80个整数。 br />
-
Ian Collins。
You are only setting the first 80 bytes of the the array, not 80 ints.
--
Ian Collins.
这篇关于memset o / p不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!