How to write, compile, and execute a hello, world program with Dev C++ and the Command Prompt

Only proceed if you've successfully installed Dev–C++ and have modified your path.

Step 1

Launch a command prompt window:

Windows key + R

The prompt should blink from your home directory. In my case, for example, the prompt would look like

C:\Documents and Settings\Roy Vanegas\>

Step 2

Create a directory, if you haven't already, in which to keep your source files. Let's name it c_programs. Type the following at the prompt:

mkdir c_programs

Step 3

Change into the new directory:

cd c_programs

Step 4

Launch Dev–C++, or any text editor for that matter.

Step 5

Create a new source file:

Ctrl + N

Step 6

Type the following code in the new file:

#include <stdio.h>

int main( void )
{
   printf( "hello, world\n" );

   return 0;
}

Step 7

Launch the "Save File" dialog:

Ctrl + S

Step 8

Look for the c_programs directory we just created by clicking the down arrow next to "Save in:". In my case, I have to walk through the following path:

Local Disk (C:) | Documents and Settings | Roy Vanegas | c_programs

Step 9

Name the file hello_world in the text box next to File name:, then click the down arrow next to Save as type: and choose C source files (*.c). Click Save.

Step 10

Toggle over to the command prompt:

Alt + Tab

Step 11

List the files in the directory:

dir

hello_world.c should appear in the list of files.

Step 12

Compile the source file with the following command:

gcc –Wall hello_world.c

Step 13

List the files again:

dir

hello_world.exe should appear in the list of files.

Step 14

Run the program by typing the following at the prompt:

hello_world

Conclusion

Congratulations! You've just written, compiled, and run a C program.