How do I run C programs on a Mac? [duplicate]

I just want to run this simple Hello World program but I don't know how to. I am using sublime if that helps.

16.4k 18 18 gold badges 86 86 silver badges 146 146 bronze badges asked Jan 6, 2017 at 20:23 user3064228 user3064228 81 1 1 gold badge 3 3 silver badges 8 8 bronze badges maybe check this out: How to run C program on Mac OS X using Terminal? Commented Jan 6, 2017 at 20:26 Go to the directory the file is saved in in terminal, then run make [filename] then run ./[filename] Commented Jan 6, 2017 at 20:26 Also, you don't need to include stdlib Commented Jan 6, 2017 at 20:27 . in this case. Because you don't rely on anything declared therein. Commented Jan 6, 2017 at 20:27 @JohnBollinger Sorry, that's what I meant. Obviously you need to for some programs. Commented Jan 6, 2017 at 20:28

1 Answer 1

Use the C compiler from terminal in Mac, like:

cc -o outputFileName inputFileName.c 

The output file is executable, so you can double click it or in the terminal simply provide the path to the file. If your working directory is already holding that outputFileName (check with ls -al ) then you can type:

./outputFileName 

The program will then execute.