Learn how to easily set up, write, compile, and run C and C++ programs in Visual Studio Code (VS Code) on macOS! This step-by-step tutorial covers everything from installing the Clang/LLVM compiler via Xcode Command Line Tools to configuring VS Code extensions and running your first "Hello World" program.
Perfect for beginners, students, and developers working on Intel or Apple Silicon (M1, M2, M3, M4) Macs.
👇 Timestamps:
1. Open your Mac Terminal and install the compiler:
xcode-select --install
2. Verify the installation by checking the clang version:
clang --version
3. Download and install Visual Studio Code for Mac.
4. Open VS Code and install the official "C/C++" extension pack by Microsoft.
5. Create a new file named `main.cpp`, write your code, and save it.
6. Use the shortcut 'Cmd + Shift + B' or click the "Play" button in the top right to build and run your C/C++ program using the C/C++ Runner extension.
---
🔧 Common Troubleshooting:
If you get a "gcc not found" or "g++ not found" error, make sure Xcode Command Line Tools are fully installed.
Ensure your file extension is strictly `.c` for C programs or `.cpp` for C++ programs so VS Code recognizes the language.
#VSCode #Cpp #MacBook #CProgramming #CodingTutorial #Developer #AppleSilicon