First C++ program on OSX
Installed Xcode 2 with high hopes. Unfortunately, I was lost on the way to run my first c++ program. But then I gave it a try on the Terminal using vim editor. If you are interested, here are the instructions.
It is boring to edit on vim if you have no syntax highlighting. To make it work you should create a file called .vimrc on root directory of the user.
Open the Terminal and type vim .vimrc (When you first open the Terminal you will be on the root directory of the user)
Press "I" to get to insert mode.
Type syntax on
Then press esc button and type :wq to save and exit from vim editor. Next time when you use vim to write a program syntax highlight should be active.
To create your first C++ program
Open the Terminal and type vim first.cpp
Press "I" to get to Insert Mode and type this small program.
Then press esc and :wq to save and exit from vim editor.
Next step is to compile your program. To do that
Type g++ first.cpp -o first and press Enter
This will create an executable file called "first". If you followed my instructions correctly the Terminal should be ready to execute the next command.
Type ./first and press Enter to execute the file.
You should see "Hello World!"
Hope you enjoyed running your first c++ program on osx.
Novice
It is boring to edit on vim if you have no syntax highlighting. To make it work you should create a file called .vimrc on root directory of the user.
Open the Terminal and type vim .vimrc (When you first open the Terminal you will be on the root directory of the user)
Press "I" to get to insert mode.
Type syntax on
Then press esc button and type :wq to save and exit from vim editor. Next time when you use vim to write a program syntax highlight should be active.
To create your first C++ program
Open the Terminal and type vim first.cpp
Press "I" to get to Insert Mode and type this small program.
Then press esc and :wq to save and exit from vim editor.
Next step is to compile your program. To do that
Type g++ first.cpp -o first and press Enter
This will create an executable file called "first". If you followed my instructions correctly the Terminal should be ready to execute the next command.
Type ./first and press Enter to execute the file.
You should see "Hello World!"
Hope you enjoyed running your first c++ program on osx.
Novice