Prime numbers program

后端 未结 14 1626
无人及你
无人及你 2021-01-07 00:27

I\'m currently trying out some questions just to practice my programming skills. ( Not taking it in school or anything yet, self taught ) I came across this problem which re

14条回答
  •  渐次进展
    2021-01-07 01:07

    It looks like as you go around the main for() loop, the value of b increases.

    Then, this results in a crash because you access memory off the end of your array:

                    for (int d = 0; d <= b; d++) {
                        c = num[d];
    

    I think you need to get the algorithm clearer in your head and then approach the code again.

提交回复
热议问题