Xcode: lost connection with Error code -1

前端 未结 1 1490
[愿得一人]
[愿得一人] 2021-01-22 18:41

This seemingly trivial piece of code is copied from the textbook but after Xcode takes the input at the scanf(), the program exits with error code -1 and says \"lost connection\

相关标签:
1条回答
  • 2021-01-22 18:52

    Since the program expects an integer value to be inputted, I was hitting the "Enter" key on my keyboard (on the number pad). The scanf method terminates user input after the "Return" key is pressed. Although they are both often referred to as "Enter" keys, they behave very differently in this context.

    Also, if you would like to use the "Enter" key, you can add a forward slash to the end of the input and then press "Enter" which would return the same results as the "Return" key.

    Silly me.

    0 讨论(0)
提交回复
热议问题