In this C programming language tutorial we take another look at the printf function. We will look at how to use format specifiers to print formatted output onto the screen. The topics covered are; a little printf background, format specifiers and conversions, formatting of different types and format conversions of strings. More »
Posted in C Tutorials |
Important: Before you start this tutorial, did you follow the pointers and more on pointers tutorials? Strings and pointers are intertwined to a large extent.
A string in the C language is simply an array of characters. Strings must have a NULL or \0 character after the last character to show where the string ends. A string can be declared as a character array or with a string pointer. First we take a look at a character array example: More »
Posted in C Tutorials |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |