C++: Compiling a simple C++ program on Netbeans

This entry is part 40 of 61 in the series C++

Now that we have configured the C++ compiler in Netbeans, we can test it out by running a simple C++ program to see if we have the Compiler properly installed.

1. From the menu in Netbeans, go to File -> New Project.

2.

cygwin11

3.  As in the screenshot above, in the Categories, select C/C++

4.  In the Projects column, select C/C++ Application.  Click on Ok.

5.  In the next windows, you can leave it as it is and click on Finish.

compiler

6.  Under the source file, you should see a main.cpp

7.

compiler1

8. Click open it and you can see a template being created for us.

9.  We will add the iostream library and a cout statement to display a string as shown below.

/* 
 * File:   main.cpp
 * Author: daryl
 *
 * Created on January 24, 2015, 11:07 PM
 */

#include <cstdlib>
#include <iostream>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    
    cout << "Hello, World";
    return 0;
}

10. Now click on the green arrow button or press F6 to run the program.

11.

compiler2

 

Series Navigation<< C++: Configuring Cygwin compiler to work with Netbeans
C++: Array >>

Leave a comment

Leave a Reply