scanf() misbehaving

前端 未结 3 415
野性不改
野性不改 2020-12-22 06:07

I have a very short snippet that reads in an integer:

#include 

int main() {
    while (1) {
        int i = 0;
        int r = scanf(\"%d\",         


        
3条回答
  •  无人及你
    2020-12-22 06:33

    Sounds like you are not clearing the input buffer and leaving the incorrect char to be scanned over and over.
    See here:
    Scanf and loops
    and
    scanf not terminating

提交回复
热议问题