Working in Windows
As you have noticed, like many other programming languages, you can use the C language in several different systems.
This page will show you how to use C in Windows. You will actually use a compiler commonly associated with Linux called GNU, inside a package called MinGW (Minimalist GNU for Windows). Let's get started.
Downloading and Installing MinGW
Open a browser and go to https://sourceforge.net/projects/mingw/ to access MinGW (Minimalist GNU for Windows). The following will be displayed. Select the green Download button.
This will lead to the following screen.
View the licence as needed and select Install.
You can leave the configuration as is and select Continue.
Again leave the configuration as is and select Continue.
Select all the options as shown. None of these require very much hard drive space.
Once all the options have been checked, go to Installation, and select Apply Changes as shown here.
This leads to the verification window where you can select Apply.
The download process will engage as shown here.
After the downloads, the files will be extracted as shown here. When completed, you can select Close.
At this point, you can verify that all the boxes are green.
Now go to your File Explorer, as shown.
Go to your C: Drive, shown here on the left.
Double click on the MinGW directory as shown.
Double click on the bin directory, shown here.
Click in the top bar to show the path of the bin, as shown here. Press Ctrl-C to copy this.
Now right click on the Windows Start button in the lower left corner, and select System as shown.
Type Environment in the query box, upper left, and select the Edit the system environment variables item that is displayed.
Select the Environment Variables… button, shown here.
Double click on the Path item, shown here.
Select the New button, shown here.
Type Ctrl-V to paste the MinGW bin path into the line, as shown here, and then select OK.
Again, select OK, as shown here.
And select OK one more time, as shown here.
This should take care of your setup but it is worth verifying. In the search bar at the bottom of your Windows screen, type cmd, as shown here.
In the command line window, type gcc --version as shown here.
When you press enter, you should see the following. This verifies that you have MinGW installed and configured correctly, as shown here.
Finally, you need to configure your workspace.
You can create a workspace immediately under your User directory by typing mkdir Projects or whatever you like. However, don’t place any spaces in the directory name. You could use CS136_Projects but don’t use CS 136 Projects as there may be problems with this later on.
Here is an example of creating a directory as described.If you type dir here, you will see the directory you created, as shown.
If you type cd CS136_Projects, this will move you to that directory, as shown.
As you create your projects, you should start a new directory under your projects directory for each one, using the same process described. Here is a example.
You move to that directory the same way as you moved to the projects directory, as shown.
Finally, you are now ready to test your compiling process. Create a file using Notepad, as shown here.
Save the file to your project location, as shown here.
Now go back to your command line by typing cmd in the search bar at the bottom of your screen, shown here.
Navigate to your working directory, as shown here.
Type dir to verify the file is there, as shown.
Now type gcc -Wall testprog.c -o testprog.exe as shown. Unless you have warnings or errors, nothing is displayed but the prompt returns as shown.
Now type testprog and watch the fireworks!
Once you have done this, you are ready to get to work on your programming. Enjoy!