This is the first part of a 12 part series of blog posts about programming in the C language. This tutorial will guide you through learning C programming, but since there are already a lot of different tutorials out there on the web to learn the basics of programming I’ll not give you yet another tutorial on the exact same thing. These tutorials will instead give you a small description of the different pieces making up the C language. It will give you some links to learn the absolute basics and then continue with a discussion. My hope is that this discussion will enhance your learning, giving additional tools to understand the content on the other sites. The discussion will also hopefully give you additional value in understanding more about the possibilities, limitations, and usefulness of different concepts in different situations.
Table of Contents
The 12 parts are made up of the following posts:
- Introduction to C programming
- Data Types
- Allocating Memory
- Error Handling
- Other Goodies
Introduction to C programming
There’s a lot to learn when learning to program for the first time. You’ll have to put a lot of hours to learn in all but don’t worry, the time spent now will give you many benefits. Some of these benefits will show right away, programming is fun (at least to most who later end up as programmers, developers, system engineers, mathematicians, teachers, CEOs, hobbyists and many others), but it’s also a great way to solve problems, learn about and apply logic, create digital art of different kinds (both music and visual graphics in 2D or 3D can be done with programming). There are many reasons for enjoying programming as you learn it and you can also let the reason you like best decide which kind of programming you’ll learn.
There are many different kinds of programming out there and there are a lot of different things you can do. Most programmers end up specializing themselves into a specific field of their own interest. This freedom of being able to choose your field yourself enables programmers to work with what they want and also give each of them a distinct fingerprint to their work. But before coming to this point each programmer must start out somewhere and I believe that C is a great starting point for many reasons.
C is a high-level language, which means that it abstracts away many of the difficult parts of programming such as remembering different commands for different actions for different systems. It allows you to use a small set of tools to do practically all types of programming while still allowing you to use libraries of ready-made code to increase work pace. With C you can build programs for robots, create your own game or software application and much more. C also shares a lot of similarities to a great array of languages, by learning C you’ll effectively have a much easier time to learn other similar languages later. In many cases, the process of learning a new C-like language after knowing C will be to just understand the few differences between the two. So if C takes a few months to fully learn then each consecutive C-like language will take perhaps a week or two to learn.
So to give a brief introduction to C you can watch the following videos and read more on tutorialspoint. Afterward, there will be a discussion with some more information about C which might be useful to know. The suggested parts to read are the following:
If you feel like you really want to take the hard-core route when learning C and if you perhaps already have some knowledge in Linux or the terminal then you might want to read this https://www.tutorialspoint.com/cprogramming/c_environment_setup.htm and this https://www.tutorialspoint.com/cprogramming/c_program_structure.htm. If you choose to take this route then make sure to look more into GCC.
After reading watch the following videos to learn more, Bucky has been around for a long time and even I learned to programme in C from his videos a long time ago.
So after reading and watching all of this, I think we’re ready for a more in-depth discussion. In this information, you’ve learned some of the basics of programming and how to set up and get started with your programming environment. This is essentially the tools you need to get started but I think that it can be beneficial to learn more in-depth what programming is about and how it works to better understand not only what you do but why you do it in a certain way.
In this discussion, we will take a look using a top-down and a bottom-up approach. Let’s begin with the top-down.
If we look at programming from a top-down approach it’s all about manipulating data. You can look at programs as a set of functions which pass data along each other to end up as a result. The functions can, in turn, do different things if you want to know the sum of two numbers a function solving that can take two numbers and pass you the sum of them. If you need to know the sum of three numbers the same function can take two of the numbers, add them together and then run again with the sum of the first two as one input and the third number as a second and pass you the sum of those, effectively giving you the sum of all three.
When programming games or other simulation software, your end result is not a value but an experience which happens during the execution (run) of a program. But in the simulation of the program, there’s still a lot of functionality going on, there are matrixes being manipulated to provide you the illusion of 3D movement, or audio being processed (in fact also often as matrixes or arrays) to enable sound.
This might not make much sense or matter much when just starting out, but I think it’s important to look at your programs as functions that manipulate data and pass it along. If you think like this you’ll more easily see solutions to problems, there’s often a way to create or combine functions to solve them!
So that was a top-down view on programming, but if we stop being very theoretical and get more practical instead we can ask the question, what happens inside the computer when programming?
This is indeed an interesting question. In the computer, there are a lot of data being held stored, either on the hard drive (slow), RAM (fast) or CPU cache memory (fastest). This data is operated by the operating system and used in your C programs. When developing you’ll encounter things such as types which are singular points of data and arrays which are several pieces of data grouped together. These groupings can be stored in different places in the computer, as a file in the hard-drive or as an instance of a program in the RAM or cache. When beginning programming you’ll not think a lot about where the data is stored and retrieving it will be handled by the operating system. But later when you’ll want to optimize programs and allow loops to go through arrays of data more effectively, you’ll start to look at where the data is retrieved from and how it’s retrieved.
Summarized you could say that all that programming is about is taking data from the computer and manipulate it with functions in a program and then put the data back into the system. Whatever you program it will be the same story, but what you do with it and for what purpose can be really diverse. The data manipulation can be used to create everything digital we see around us today. Computers, tablets, phones, cars, ovens, microwaves, alarm clocks, robots, vending machines etc.
For now, I think I’ll end my discussion here and instead you can continue on with the tutorial to learn more about C programming and start creating your very own programs! Did you like the post and/or did you think that I left out something important which you want to add or ask about? Like the blog post and leave a comment below, spread the word about it chats or social media, I’ll really appreciate it!