Getting started C/C++ on Mac

It’s very easy to start C/C++ on Mac.

Install Xcode and Command line tools

You need to install Xcode. Open App Store and install “Xcode”. 

Editor

Various free editors are available. You can choose whatever you like. Usually, I use CLion. As for the free editor, I recommend visual studio code.

Download and Install

Visit https://code.visualstudio.com/.

Download and install visual studio code. 

Install C/C++ extension.

Open visual studio code and install C/C++ extension. It makes your coding easy.

Write code

File->new file and write down (or copy and paste) the following code.

Save the file (File -> Save As) as “HelloWorld.cpp”.

Open terminal

Open terminal and move to the directory where you save HelloWorld.cpp. Compile HelloWorld.cpp as follows.

> c++ HelloWorld.cpp
> ./a.out
Hello, World!

You can see “Hello World!”. Congratulations.

Leave a Comment

Your email address will not be published. Required fields are marked *