Introduction: How to Make a Simple C Program

Picture of How to Make a Simple C Program

These instructions will show you how to construct a very basic C program. Currently computers are found in almost every household in America and programming is a method that lets us interact directly with them. Thus I created this instruction for anyone with a windows computer to follow. People with no programming knowledge might spend 30 or so minutes, but those with more experience will take less time. By the end of the instruction you should have a working program that you constructed yourself.

Needed Things

  • Windows computer
    • Admin access may be needed
    • Adaptations can be made with other computers
  • Internet connection

Step 1: Downloading Software

Picture of Downloading Software
Note: If you are running a non windows computer this step and the one that follows won't pertain to you.

1. Click on this Link > MinGW

2. Click the Download link on the webpage

Figure 1
Note: You will be redirected to the page in Figure 2

3. Click the Download link on the new webpage

Figure 2
Note:You will be redirected to the page in Figure 3

4. Wait till the download completes

Figure 3
Note: Can take awhile

5. Navigate towards your computers downloads folder

Step 2: Install the Software

Picture of Install the Software

1. Run the Installer

Note: you might run into a popup, just hit run as in Figure 4

2. Click on the Install button

Figure 5

3. Uncheck the Graphical User Interface box

Figure 6

4. Click the Continue button

Figure 7

5. Wait for the software to download

Figure 8

6. After the software has finished downloading click on the Quit button

Figure 9

Step 3: Create the Code

Picture of Create the Code

1. Open Notepad

Click the windows button then type "notepad" as in Figure 10
If done right should end up at Figure 11

2. Type the files to include

#include <stdio.h>
Figure 12
Note: You can add other files you would like to use, we will include this so that we can have output

3. Add the Main Statement and the brackets

int main( int argc, const char* argv[] ) {

}
Figure 13

4. Add the Printf Statement within the brackets

printf("Hello World! Made by [insert name].");
Figure 14
Note: replace [insert name] with your name for added personalization

5. Save the File as a .c file

Figure 15 then Figure 16

Step 4: Compile and Run

Picture of Compile and Run

1. Open Command Prompt

Click the windows button then type "cmd" as in Figure 17
If done right should end up at Figure 18

2. Type in the GCC command

gcc First.c -o First
Figure 19

3. Type in the command to run the program

./First
Figure 20

Step 5: Finished

There you have it you have constructed your first C program. Now adapting the simple code we constructed you can make more complex programs. If you experienced any problems try the MinGW webpage, there is a troubleshooting section. If that doesn't fix the problem try going over the instructions again. If neither of those help you try asking your questions on Stack Overflow.

Comments

RenOneil (author)2015-08-14

Everytime I use gcc, it says it's not recognized as an internal or external command, operable program or batch file. What does that mean?

pfred2 (author)2015-03-25

Why do you need a Windows computer? Being UNIX-alike Linux is made to be an IDE.

pfred1@buck:~$ gcc -v

gcc version 4.7.2 (Debian 4.7.2-5)

Branden Sammons (author)pfred22015-03-30

I know that is why I stated that the some steps weren't necessary, but the instuctable was based around a windows machine. However could be easily adapted for Unix machines. Utilizing a notepad like application and the native gcc compiler you could follow these instructions as well starting at step 3.

larry03052 (author)2015-03-25

Ming is a very good and well-maintained port of gcc to the Windows environment, but it is a very heavy and complex program for a casual coder. Let me recommend tcc at http://bellard.org/tcc/ - it requires no installation, no admin access, and is just a single zip that can be unpacked and used anywhere. It is much faster than gcc, although it produces considerably inferior quality code - but it is ideal for a beginner to experiment with, and the full source of the compiler (which can compile itself) is open source as well. You can also use it as a c-scripting environment (compile-and-go) which skips linking and the like (confusing for beginners) and lots of other very handy attributes. Check it out.

gomibakou (author)2015-03-25

ey, step 3 adding code shows the html used in the site mixed with the C code, newbies could be confused with that if they copy it.

Oh darn I didn't even see that thanks

About This Instructable

1,703views

19favorites

License:

More by Branden Sammons:How to make a simple C program
Add instructable to: