C++ - dev c++ - Programming Languages

Dev C++ Explained for All Levels

As you work towards becoming a C++ developer, there will be several days where you’ll simply have to sit down and write some code. 

To create a successful program, you’ll need to ensure that you have the proper tools in place — including a suitable integrated development environment (IDE). 

This article looks into one such early IDE, Dev C++, and shows you how it works in an example scenario.

Let’s get started!

What is Dev C++?

Dev C++ is a complete IDE for the C++ language

The IDE uses a MinGW port of GCC (GNU Compiler Collection) as its compiler. MinGW is a minimalist approach to write executables for Windows systems. Dev C++ is also usable with Cygwin or any other GCC-based compiler. It was first built in Delphi and was upgraded using Delphi’s latest version.

Millions of users have used Dev C++ since the first version was released back in 1998 by Bloodshed Software. Having been around for over 20 years, the IDE remains a popular learning tool for universities worldwide.

Bloodshed abandoned Dev C++ in 2006 when the team no longer had the time to support it. The software was picked back up in 2010 by Johan Mes, an independent programmer who goes by the name Orwell. After 10 years of working on the IDE, Orwell stepped away from the project. U.S. software company, Embarcadero Technologies, subsequently began sponsoring the IDE and now maintains it.

In addition to being fully functional with C++, Dev C++ also works flawlessly with C. Currently, the Dev C++ IDE is only available on the Windows 7, 8.1 and 10 operating systems.

What Is an IDE?

Integrated development environments like Dev C++ are essential tools that combine a source code editor and a compiler into a single user interface. These software platforms provide programmers and developers with a comprehensive list of tools to develop a software product.

A typical IDE contains a source code editor for writing software. These editors usually feature syntax highlighting for code readability, visual cues and prompts, and auto-completion specific to the language you’re using.

Once a program is written, IDEs can also compile code into an executable program while checking for errors. Programs run within the IDE can be tested for bugs and correct prompts and outputs.

When things don’t go according to plan, IDEs also provide debugging tools to help you locate those pesky errors in your code without you having to scan everything line-by-line. Many IDEs provide hints while coding to prevent errors before the compilation stage.

Downloading and Installing the Dev C++ Software

Dev C++ is easy to download and use. Although it can be downloaded in multiple places, the Dev C++ GitHub repository keeps a list of releases with detailed update information for each release.

You’ll likely want to download the IDE with the MinGW compiler unless you have another compiler that you prefer to use. Assuming you do download the IDE with the compiler, approximately 70 megabytes is all that stands between you and the setup files. After running the executable, picking your language, and choosing an install location, Dev C++ will be installed on your machine.

Pro tip: Once you open Dev C++ for the first time, you will want to enable the IDE to generate helpful debugging information as you code. To do so, navigate to Tools -> Compiler Options. Open the “Settings” tab, followed by the “Linker” tab. Once in that window, make sure that “Generate Debugging Information (-g3)” is toggled to “Yes.”

Dev C++ Example

Here’s a screenshot of what Dev C++ looks like when started up:

To build a program, choose the “New Document” button on the right-hand side, which will bring you to the screen where you can write your code.

Dev C++’s interface is user-friendly and takes a lot of the guesswork out of creating a program. At the top of the screen, you’ll see buttons linked to hotkeys that quickly let you compile a program, run it or do both. It’s worth noting that your output will appear in a separate window and not in the Dev C++ software itself. Should something not go according to plan, the user interface also has a hotkey for the debug feature we enabled to try and track down any mistakes.

Using the Dev C++ software, we created a random number generator for a twenty-sided die. Here’s how the program looks in Dev C++:

And, here’s the same program that you can copy and use in Dev C++ on your device.

#include<iostream>
#include<time.h>
#include<stdlib.h>

using namespace std;

return randnum()
{
  int rolls;
  int random;
  int min = 1;
  int max = 20;
 
  cout << "Enter the number of d20 rolls" << endl;
  cin >> rolls;
  cout << "Your " << rolls << " dice rolls are " << endl;
  srand(time(NULL));
  for(int i=0;i<rolls;i++)
  {
    random=rand()%max + min;
    cout<<random<<endl;
  }
}
int main()
{
  randnum();
  return 0;
}

We start by declaring our int values for the number of rolls, the result, and our criteria for the maximum and minimum number on the die. We prompt the user to input how many dice rolls they need to emulate and then let the program “roll” that number of times. The program uses a for loop for this, which will terminate once “i” is greater than the number of rolls required.

The output might look like this:

Enter the number of d20 rolls
5
Your 5 dice rolls are
1
6
19
20
19

We started off with some low rolls, but ended strong.

Alternatives to Dev C++

Millions have used Dev C++ over the years, and it’s kept up-to-date with a modern user interface and style customization options. One of the more notable uses of Dev C++ is current Singapore Prime Minister Lee Hsien Loong, who used Dev C++ to create a Sudoku solver program.

Should Dev C++ not end up being your cup of tea, worry not. At Udacity, we’ve compiled a list of some of the best IDEs for C++ that you can also try out.

What’s This About Bloodshed?

Company Bloodshed Software developed Dev C++ back in 1998. The name “Bloodshed” left many people wondering about the true nature of its creator, Colin Laplace.

Laplace clarified the use of this gruesome name by saying he doesn’t enjoy violence, war, nor does he like heavy music. Although French, he understands the meaning of the name but just liked how it sounded.

One of Bloodshed’s many users stated that he thought the name could reference the time and effort it requires to create such a software program. The “Blood, Sweat, and Tears” that go into such a design should not be forgotten.

Master C++ With Udacity

You won’t make it very far in the world of C++ without knowing your way around an IDE like Dev C++. To get the most out of your IDE and master the C++ ecosystem, check out our expert-taught C++ Nanodegree, where we’ll challenge you to code five programs of your own.

Enroll in our C++ Nanodegree program today!

Start Learning