How to compile and run C in Xcode

xcode

Our teacher is teaching use some Data Structures algorithms that are being implemented in C. He uses Visual Studio in class, but I want to be able to run simple programs that we write in Xcode.

I've tried to run the code but in Xcode 5 the options to do so are greyed out. Besides just installing Xcode, what steps should I need to take so that I can run simple C programs on my Mac?

Best Answer

  • Open Xcode
  • Select File->New->New Project
  • Select macOS (OS X in older versions) -> Command line tool
  • Choose C as type
  • Fill out the name and the other relevant wizards parts you need
  • click the main.c file to select it

And you should be good to go