Friday, February 23, 2018

C++ with Mac: Hello World with Mac's Terminal

This post shows how to execute a C++ hello world program with the following steps:

1. In terminal, create a C++ file called hello.cpp:

nano hello.cpp

2. Edit the hello.cpp file as:

#include <iostream>

using namespace std;

int main() {
    cout << "Hello, World!\n";
    return 0;
}

3. In terminal, execute the file with:

g++ hello.cpp
./a.out

Result:


References

Compiling simple Hello World program on OS X via command line (StackOverflow)
C language with Mac: Hello World with Mac's Terminal
Matlab: Run Hello World files in C/C++ with MEX command

Saturday, February 10, 2018