Using Integer Variable as Index in scanf

后端 未结 2 948
半阙折子戏
半阙折子戏 2021-01-25 02:22

I\'m trying to do the below in my function but keep getting a segmentation fault error. It\'s failing when I\'m trying to use [iModify - 1] as my index.

Can

2条回答
  •  灰色年华
    2021-01-25 02:28

    You have used char name_num[] = {'\0'}; in your code. name_num has the length of 1 char, which is too short to hold a string later.

    Therefore, you are writing out-of-bounds when you read name_num.

提交回复
热议问题