局部变量未初始化问题

记得有次编程中忘了初始化变量,这导致了计算结果不正确,debug后发现未始化造成的,现记录此问题也让大家不要再进坑了!

上代码:

debug发现TotalAA值很大(7.9434E+125)不对,后设断点一句句运行,发现声明完未始化造成.

改成如下,结果正确:

看来养成良好的编程习惯也是编程的一部份。

《局部变量未初始化问题》上有2条评论

  1. Appreciation to my father who stated to me on the topic of this webpage, this web site is truly awesome.

评论已关闭。