C Tutorial – More on Pointers

In the previous C programming language tutorial we looked at the fundamentals of pointers. In this C tutorial we will look at some specifics of pointers.

Initialize a pointer

Before you can use a pointer in for instance a printf statement, you have to initialize the pointer.
The following example will not initialize the pointer: More »


Posted in C Tutorials | 32 Comments


C Tutorial – How to use Pointers

To make full use of the C Programming language, you have to have a very good understanding of pointers. For most people it will take some time to fully understand pointers. So be patient. You have to learn pointers because they are used everywhere in the C language. Once you master the use of pointers, you will use them everywhere. OK, enough pep talk, let’s start. More »


Posted in C Tutorials | 60 Comments


C Tutorial – More on Functions

In this C programming language tutorial we will talk some more about functions. We will take a look at command-line parameters and function prototypes.

Command-line parameters

In some cases you want to give a parameter at the start of a program.
For example: More »


Posted in C Tutorials | 3 Comments


C Tutorial – Functions and Global/Local variables

Most languages allow you to create functions of some sort. Functions are used to break up large programs into named sections. You have already been using a function which is the main function. Functions are often used when the same piece of code has to run multiple times.

In this case you can put this piece of code in a function and give that function a name. When the piece of code is required you just have to call the function by its name. (So you only have to type the piece of code once). More »


Posted in C Tutorials | 23 Comments


C Tutorial – Arrays and Multi-Dimensional Arrays

In this C programming language tutorial, we are going to talk about arrays.

An array lets you declare and work with a collection of values of the same type. Let’s say you want to declare four integers. With the knowledge from the last few tutorials you would do something like this: More »


Posted in C Tutorials | 26 Comments


C Tutorial – for loop, while loop, break and continue

In every programming language, thus also in the C programming language, there are circumstances were you want to do the same thing many times. For instance you want to print the same words ten times. You could type ten printf function, but it is easier to use a loop. The only thing you have to do is to setup a loop that execute the same printf function ten times. More »


Posted in C Tutorials | 94 Comments


C Tutorial – The if and switch statement

In this C programming language tutorial we take a look at the “if statement” and “switch statement”. Both are used to alter the flow of a program if a specified test condition is true.

Boolean Operators

Before we can take a look at test conditions we have to know what Boolean operators are. They are called Boolean operators because they give you either true or false when you use them to test a condition. The greater than sign “>”
for instance is a Boolean operator. More »


Posted in C Tutorials | 25 Comments


C Tutorial – variables and constants

In this C programming language tutorial we take a look at variables and constants.

Variables

If you declare a variable in C (later on we talk about how to do this), you ask the operating system for a piece of memory. This piece of memory you give a name and you can store something in that piece of memory (for later use). There are two basic kinds of variables in C which are numeric and character. More »


Posted in C Tutorials | 43 Comments


First C program, Hello World

After talking about the history and compilers it is time to make our first program. We like to make C programs under Linux, so we will use a text editor and the gnu compiler. But all programs we make in these tutorials will also work under Windows. Remember, the examples included in the C and C++ tutorials are all console programs. That means they use text to communicate. All compilers support the compilation of console programs. Check the user’s manual of your compiler for more info on how to compile them. (It is not doable for us to write this down for every compiler). More »


Posted in C Tutorials | 52 Comments


C Tutorial – Compilers (GNU and Visual Studio)

A compiler is a program that translates one language (high level) into another language (e.g., assembly language or machine specific language). A compiler translates source code (plain text) into object code (normally in a form suitable for processing by other programs (like a linker)). The most common reason for wanting to translate source code is to create an executable program.

After the compiler translates the source code in object code, the object(‘s) have to be linked into an executable. This is done by a program called a linker (in most cases the compile stage and link stage are done automatically. It is also possible to do these stages separately). More »


Posted in C Tutorials | 7 Comments