Initialising int affects function return value

前端 未结 2 697
陌清茗
陌清茗 2021-01-13 20:08

Sorry for the vagueness of this question\'s title, but I\'m not sure how to ask this exactly.

The following code, when executed on an Arduino microprocessor (c++ co

2条回答
  •  悲&欢浪女
    2021-01-13 20:41

    When you don't initialise the variable it has a random value, whatever was in the memory address, so while (i <=strlen(str)) is going to behave unpredictably. You should always initialise.

    (Visual Studio Debug configurations automatically initialise variables.)

提交回复
热议问题