C Language Setup & Compilation on Mac (Without VS Code)
Step 1: Install Xcode Command Line Tools
Open Terminal and run:
xcode-select --install
Click 'Install' when prompted. After installation, verify with:
gcc --version
You should see the GCC version.
Step 2: Write Your First C Program
Open any text editor (TextEdit, Sublime Text, or nano).
Example code:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
Save the file as hello.c (e.g., on your Desktop).
Step 3: Compile and Run
In Terminal, navigate to the directory where hello.c is saved:
cd ~/Desktop
C Language Setup & Compilation on Mac (Without VS Code)
Compile the program:
gcc hello.c -o hello
Run the executable:
./hello
Expected Output:
Hello, World!
Optional Editors
You can also use these editors:
- Sublime Text
- Atom
- BBEdit
- Nano (in Terminal):
nano hello.c