My program loops forever and does only a half of what I told it to do

后端 未结 4 1002
别那么骄傲
别那么骄傲 2020-12-07 06:28

I\'m new to programming and I started to make my own Fire Emblem level up calculator, but for some reason it loops infinitely. I can\'t find an answer. Could you look for an

4条回答
  •  悲&欢浪女
    2020-12-07 06:54

    level-1; computes the value of level-1 and then throws it away, doing essentially nothing. As such, the value in level is never updated and you're stuck with an infinite loop (you are also doing this with all of your variable updates, be careful!)

    If you want to decrement the value of level (reduce it by one), you can do any of the following:

    level = level - 1;
    level -= 1;
    level--;
    

    Furthermore, if(cha[6] = 'Dieck') is not correct on several fronts. You could perhaps do

    if(strcmp(cha, "Dieck") == 0) { //...
    

    If you make sure to #include

提交回复
热议问题