Running C scripts with terminal instead of Xcode

前端 未结 3 620
时光取名叫无心
时光取名叫无心 2021-01-07 11:50

Currently I am developing a couple of C programs on my mac using Xcode. There however is 1 problem. My study requires me to use some sort of input field through the coding.

3条回答
  •  半阙折子戏
    2021-01-07 12:25

    It sounds like you need to check argc in the program as RageD points out, otherwise when launching the program with insufficient arguments will cause problems.

    gcc is the c compiler - it produces an executable. When you hit 'Run' in Xcode it compiles your program and then runs the executable file created. The executable created is named the same as your Xcode project name.

    To run the program you built in Xcode from the command line:

    • In Xcode's project navigator find the executable in the 'Products' folder
    • Drag the executable file into Terminal (You will get an absolute url to the executable)
    • add any arguments you need to run your program
    • Hit enter!

    The result will look something similar to the snippet below (for my 'MyCommandLineApp' project):

    $ /Users/pliskin/Library/Developer/Xcode/DerivedData/MyCommandLineApp-hbpuxhguakaagvdlpdmqczucadim/Build/Products/Debug/MyCommandLineApp argument1 argument2
    

提交回复
热议问题