Access violation writing location 0x00000000. reading int from keyboard

前端 未结 5 1982
悲&欢浪女
悲&欢浪女 2020-12-07 00:45

I am trying to read the input from a keyboard which i will use to create a set of multiplications. If i hardcode the integer to use then the program works fine however when

5条回答
  •  死守一世寂寞
    2020-12-07 01:37

    You are not passing the address of variable for multiple to store the result from scanf hence the requirement for scanf("%d", &multiple);.

    This is telling the runtime, to read an integer and place it into the address-of variable, hence & must be used. Without it, you got a runtime error as you are passing the value of the variable but the runtime does not know what to do with it.

    In a nut-shell, an address-of variable is indicated by &.

    Hope this helps, Best regards, Tom.

提交回复
热议问题