possible use of 'b' before definition in function main
来源:百度知道 编辑:UC知道 时间:2024/05/06 04:49:41
#include"stdio.h"
main()
{int b,i,count=0,a[10]={1,2,3,4,5,6,7,8,9,10};
for(i=0;i<10;i++)
{b+=a[i];
count+=b;
}
printf("%d",count);
}
大家帮忙看看
为什么我运行
这个程序
可以得到正确结果
但
编译器为什么
会有那个”警告“
???
果然是
能告诉我原因吗
为什么一定要赋值为0?
main()
{int b,i,count=0,a[10]={1,2,3,4,5,6,7,8,9,10};
for(i=0;i<10;i++)
{b+=a[i];
count+=b;
}
printf("%d",count);
}
大家帮忙看看
为什么我运行
这个程序
可以得到正确结果
但
编译器为什么
会有那个”警告“
???
果然是
能告诉我原因吗
为什么一定要赋值为0?
b的值没有初始化,应该改成int b=0,i,count=0,a[10]={1,2,3,4,5,6,7,8,9,10};
你如果在生命后没赋值的话,计算机就不知道b的值,从而你下一句
b+=a[i];
就无法得到正确的值了
Possible use of ``xxx`` before definition
Are all fingerprints different? What are the possible use of fingerprints in our daily life?
possible use of 'b' before definition in function main
use of electronic communication
the use of computer
the use of force
How do people make use of animals?
run out of 和use up区别
英语1(Part II. Use of English)
求助c : illegal use of floating point