Skip to content
Physics and Astronomy
Hints & tips
C language
XCode & the debugger
>scanf hangs
Home Our Teaching Resources C programming PHY3134 Hints & tips scanf hangs
Back to top

scanf under the debugger

XCode has a problem whereby if you run a program under the debugger then scanf does not work (it just hangs). Fortunately there is a simple work-around:
  1. Make sure that the debugger is running before you start your program , i.e. that there is a debug window open. If not open one with
    Debug -> Debugger
    • If you do not have a debugger window open before you start running your code it will not show you the values of all your variables.

  2. Start the program in the normal way, either by clicking the "Build and Go" button or from the menu using
    Build -> Build and Run

  3. Your code will start running with its own console window. When it stops for scanf there will be an icon at the top of the console window with the word "Attach". When you click on it, the debugger will attach itself to your program and pause.

  4. You can now click the "Continue" button on the degugger to unpause your program.
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Privacy & cookies Share
Back to top