warning: uninitialized variable //But I have initialized ! C++ Compiler bug?

后端 未结 5 1229
夕颜
夕颜 2021-01-05 13:56

Iam trying to compile this program but i get warning and when i run vc++ 2010 debugger pops up : ( Here is my code :

#include 
using namespa         


        
5条回答
  •  青春惊慌失措
    2021-01-05 14:37

    But you haven't initialized them : )))) EX: int i,minn=0,index=0; Imagine that you pass num that equals 0, at the end you would be returning uninitialized value of minn and just before that you would set mas[unknown_number]=0; which will probably cause your app to crash since you will be referencing memory that is most likely beyond your scope. You should do a check in the beggining like if(num<1)return -1;

提交回复
热议问题