Scanf causes C program to crash

前端 未结 2 1200
半阙折子戏
半阙折子戏 2020-11-30 15:03

This simple issue is causing my entire program to crash during the first input. If I remove the input, the program works fine but once I add scanf into the code and enter th

2条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 15:57

    You must pass the address of the variable to scanf:

     scanf("%c", &answer);
    

提交回复
热议问题