C Programming language course

C programming Language

The C programming language is one of the most important programming languages today, despite being one of the oldest.

Why is it important? Well, C is widely used in operating systems, compilers, microcontrollers and embedded devices (your refrigerator or car probably has code written in C). And not only that, C laid the foundation for the development of other programming languages such as Java, Objective-C, C# and C++, hence the syntax of these languages is similar.

And yes, it may not be as popular a programming language as Python or JavaScript, but it is a programming language vital to the functioning of the world we live in today.

In addition, being an intermediate level programming language (or low level, as others say) allows us to understand in greater depth how the computer works, allowing us to control the hardware or memory.

Hence its importance, and hence the creation of this course. In 28 classes you will learn the C programming language and you will lay a solid foundation for projects associated with this language.

We start the C programming course

Let’s start the course! Here you will learn to program from 0, from the basics.

But it is also possible that you already have programming experience and you are only interested in learning about the C programming language.

In either case, I am sure this course can teach you a lot.

History, features and uses of C

I tell you all about the C programming language: Who created it, its features, details and uses.

  • Dennis Ritchie and Ken Thompson as creators of C
  • Features of C
  • What is a high-level programming language?
  • What is a low-level programming language?
  • Advantages of C as a programming language
  • What is structured programming?
  • What is a typed language
  • Where C is used
  • What is a compiled programming language
  • What is an interpreted programming language
  • Importance of C as a programming language

Installing C on Windows

I explain you how to install C in Windows step by step, and we make some definitions.

  • Download DevC++
  • Download MinGW
  • What is GCC
  • Modifying environment variables in Windows
  • Downloading VS Code and installing extensions
  • How to compile a C program on Windows

Installing C on Linux

I explain how to install C on Linux, starting with the installation of GCC.

  • Installing GCC
  • Installation test
  • Installing extensions in VS Code
  • How to compile a file in C from the command terminal.

Advantages and disadvantages of learning to program in C

Structure of a C program

The structure of a C program comprises several parts: directives, main function, the code part and the return type.

This is what we will see:

  • Analysis of the structure of a C program
  • Preprocessor directives
  • The main function
  • The return instruction
  • Why do we return 0 in the main function?

What is a variable in programming

A variable in programming is a space in memory, to which we give a symbolic name and assign a value.

In this class I explain what a variable is, how it is declared and initialized, its scope, constant variables with const and macro, protected words, variable types and format specifiers.

  • What is a variable in programming?
  • How to declare a variable
  • How to initialize a variable
  • Declaring and initializing a variable in a single line
  • Local variables in C (scope of a variable)
  • Global variables in C (scope of a variable)
  • Constant variables in C
  • Constant variables declared as a macro in C
  • Protected words in C
  • Types of variables in C (int, char, short, unsigned, long)

What is a function in programming

A function in programming is a block of code that has a defined purpose.

In this class I explain what functions are, what they are used for, the prototypes and how functions are declared in the C programming language.

Additionally I tell you about a few flags that I consider very useful when compiling in GCC.

  • What is a function in programming?
  • Syntax of a function in C
  • Example of a function in C
  • Function prototypes in C
  • Configuring the extension to compile in VS Code
  • Compilation flags in GCC: Wall, Pedantic, Werror and Wextra
  • Parameter passing in C functions
  • What is Integer overflow?

Compilation process in C

I explain each of the stages of the compilation process in C: Preprocessing, compiling, assembling and linking and we approach them with a practical example.

  • The compilation process in C
  • What is compilation?
  • Example of compilation that we will discuss
  • Preprocessing stage
  • Compiled stage
  • Assembly and object code generation stage
  • Linking stage
  • Introduction to make files

Conditionals in programming

Conditionals in programming allow us to control the flow of a program, that is, which portions of code should be executed and which portions should not, based on the fulfillment of a condition.

In C, conditionals are evaluated taking into account that when a condition is false, it returns 0.

In this video you will learn about the syntax of a conditional in programming, relational and boolean operators.

  • What are conditionals (if) in programming?
  • What is false and true in programming
  • How C handles conditionals
  • What are relational operators
  • What are Boolean operators
  • Truth tables
  • Syntax of conditionals in C (IF – ELSE)

Loops in programming

Loops allow you to execute a code for a series of times until a condition evaluates to false. A loop is composed of a control statement (the condition) and the body of the loop, which is the code that is executed until the condition holds true.

In this class you will learn the different types of loops and other topics such as the ASCII table.

  • What is a loop in programming
  • Structure of a loop
  • Examples of loops
  • While loop example
  • Example of the Do-While loop
  • Example of the for loop
  • What is the ASCII table and what is it used for?
  • The continue statement in a loop

What is an array and what is it used for?

Also known as array, vector or matrix, arrays in programming are a type of data structures that contain elements of the same type.

Today I will tell you what an array is, how it is declared, what it looks like in memory, how to access elements inside the array, multidimensional arrays and much more.

  • What is an array in programming
  • How to declare and initialize an array in C
  • How to access an array element
  • How to access an array element
  • What happens in memory with arrays
  • How to get the memory address of a variable
  • The hexadecimal system and memory addresses
  • Value passing and parameter passing in a C function
  • Multidimensional arrays in C

Pointers in programming

A pointer in the C programming language is a variable whose value is the memory address of another variable. We will delve into what a pointer is, how it is declared and initialized, what dereferencing is, and what a pointer looks like in memory.

  • What is a pointer
  • What is a pointer
  • How to declare and initialize a pointer in C
  • Dereferencing through pointers
  • How to access the value of the variable that the pointer points to
  • Pointer in memory

Pointer arithmetic

A pointer is a variable whose value is the memory address of another variable. Since this is a numeric value, we can perform arithmetic operations (addition and subtraction) on it. These operations are called pointer arithmetic. Today we will see what is pointer arithmetic in the C programming language, what is the dereference operator, arithmetic on arrays and more.

  • What is pointer arithmetic in C
  • Pointer declared in memory
  • Changing the memory address by increment
  • What is a garbage value
  • Pointer arithmetic over an array of chars

What are Strings in programming

In programming, a string is a string of characters. In other words, it is an ordered sequence of characters (letters, numbers or symbols). I explain how they are declared, accessed and manipulated in the C programming language, and we also discuss other topics such as escape sequences and the NULL character.

  • What is a character string in programming language
  • How a string is declared in the C programming language.
  • The NULL character in C
  • What is an escape sequence in C
  • Strings in memory
  • String.h as a library to work with Strings
  • Using the dereference operator to manipulate string positions
  • Using the dereference operator to manipulate string locations
  • The best way to declare a string
  • Modifying a string from a function (passing by reference)

Array decay and array pointer

Array decay in C consists in the loss of its type and dimensions. In English, this concept is widely known as Array Decay. Today we detail how array decay is generated in the C programming language, but we also talk about array pointers and the difference between pointer to the first element of the array type (*) and pointer to the complete array type (*)[n], which leads us to talk superficially about pointers to pointers.

  • What is array decay in the C programming language
  • Example of array decay
  • Difference between pointer to array and pointer to first array element
  • Pointer to entire array in memory
  • Increment in an array pointer
  • Accessing the array itself from the array pointer
  • Getting the array size from another function

Pointer to pointer in C

A pointer is a variable that has the memory address of another variable. What happens if we declare a pointer whose value is the memory address of another pointer?

That’s what we find out today, because we talk about pointers to pointers in the C programming language.

Command line arguments

From the command line you can send arguments to your program in C. And you can do it through argc and argv, being the first an integer that has the number of arguments that we pass and argv a pointer to an array of strings, which contains the arguments that we are passing.

I’m going to tell you how to work with argc and argv, and of course we experiment with memory and continue to strengthen our knowledge of arrays, strings and pointers.

  • What are command line arguments (argc, argv)
  • What is argc – argument counter
  • What is argv – argument vector
  • What is argv – argument vector
  • Example of argc
  • What are attribute directives in the C programming language?
  • Example of argv
  • Difference between char *argv[] and char **argv
  • Example of argc and argv with memory addresses

What is recursion and when to use it

Today we talk about recursion. You will be able to understand recursion in the C programming language (and actually for any language) through multiple examples. We will deepen about concepts like stack and segmentation fault, the difference between recursion and iteration and when to use one or the other, we will also perform a small benchmark to see which option is faster and you will learn tips to choose one or the other option.

  • What is recursion
  • Basic example of recursion
  • What is segmentation fault
  • Recursion in memory
  • What is stack in C
  • Example of recursion in C with Factorial
  • Recursion VS Iteration
  • Benchmark recursion and iteration with Factorial in C
  • Fibonacci as recursion and its impact on time
  • When to use recursion

The preprocessor in C and how to use it

While we already talked about preprocessing as a compilation step, there are some interesting things we can do with the preprocessor at the code level.

Today we talk about predefined macros, preprocessing operators and parameterized macros.

  • What are preprocessor directives?
  • What are predefined macros
  • How to create a parameterized macro for logging

What is dynamic memory and what are the memory segments?

The layout of the memory in the C programming language can be divided mainly in 4 zones or segments.

The first one is the .text segment, which contains the instructions of the program. Then we have the segment containing the global and static variables, which in turn is divided into bss and ds register. The next segment is the stack which we have already talked about in other classes of this C course and finally we have the heap segment which is managed through malloc (memory allocation) and free, both destined to the dynamic memory.

This last one is the one we will understand in more detail given the importance of dynamic memory in the C programming language.

  • How memory is divided in the C language
  • Text segment in memory
  • Static / global segment in the memory layout
  • What is the stack in memory and stack frames
  • What is block starting symbol
  • What is data segment register
  • Types of memory in C
  • Automatic memory
  • Static memory
  • Dynamic memory
  • Advantages and disadvantages of each memory segment
  • Code execution per memory region
  • Limitations of the memory stack
  • What is a VLA or variable length array
  • What is heap in memory layout

What is malloc and free for dynamic memory

Today you will learn how to use malloc and free to allocate dynamic memory. We will detail all the use cases of malloc: 1) when there is not enough space to reserve, 2) contiguous blocks of memory 3) how to free allocated memory and many more.

  • Why dynamic memory is necessary
  • A local variable cannot be accessed outside its scope.
  • Malloc to allocate dynamic memory
  • Sizeof function as parameter of malloc
  • Dereference operator as parameter of malloc
  • Whether or not the result of malloc should be cascaded
  • Insufficient space to allocate memory with malloc
  • Free to free memory
  • Allocating contiguous blocks of memory

How to detect memory leaks

Valgrind is a tool that runs in Linux environments and that will allow us to analyze the memory leaks of our C program. Today I tell you how to use it, how to analyze the reports and much more.

  • Installing Valgrind on Linux
  • How to analyze memory leaks with Valgrind
  • Get exact memory leak line
  • Other Valgrind features

How to use calloc and realloc to manipulate dynamic memory

Calloc and realloc are C programming language functions that complement dynamic memory management. Calloc is very similar to Malloc in its syntax and way of use, the big difference is that besides reserving dynamic memory, it assigns zero to all reserved values.

On the other hand, realloc or reallocation memory, allows you to change the size of the previously allocated dynamic memory.

We will talk about what are calloc and realloc functions and how they are used in C.

  • What is calloc and how is it used
  • What is realloc and how to use it
  • Example of calloc in C programming language
  • Example of realloc in C

File manipulation in C (File IO): Open, Read, Modify

We detail how to open, read, modify and close files in C through functions such as fopen, fputs, fputc, fwrite and fclose.

This leads us to detail concepts such as end of line (EOF) and to deepen in C functions such as exit and fprintf.

We will also talk about standard streams or input and output streams, explaining what standard input, standard output and standard error mean and what they are useful for.

We detail many topics:

  • File pointer
  • Opening a file in C: fopen
  • What are standard streams: stdin, stdout and stderr
  • Exit function in C
  • fgetc and fgets functions
  • How to close a file in C: fclose
  • How to use standard error or stderr
  • How to modify a file in C
  • fputc and fputs functions
  • Function fprintf and its difference with fputs
  • fwrite function
  • Difference between fopen and open (system call functions)

Structs and typedef in C

Structs in C are variables related under the same name. These variables can be of different types, unlike arrays in which their elements must be of the same type.

In this way, through structs or structures in C, we can represent a record.

Today I will tell you what they are, how structures are implemented in the C programming language, as well as their relationship with typedef and the usefulness of pointers to structures.

  • What is struct in C
  • Syntax of struct in C
  • How to declare and initialize a struct
  • Difference between char array and char pointer
  • What is a designated initializer in C
  • Structure inside another structure
  • Pointer to struct or how to work with pointers to structs
  • Typedef for structs

Variadic functions in C

Variadic functions are functions that can take a variable number of arguments. Syntax, how they are implemented and practical examples of variadic functions is what we will see in the C programming language.

  • What is a variadic function in C
  • Syntax of a variadic function
  • Example of a variadic function

Conclusions of the C programming course

We finished the course to learn how to program in C. We have learned from the most basic programming concepts such as variables, functions, conditionals, loops and compilation process, to more advanced topics such as pointers, memory manipulation, variadic functions and file management.

But, there is still a lot to learn in C. Today I want to tell you what’s next after this course.

Leave a Comment

Responsable de tus datos: Diego Betancourt. Finalidad: Moderación de los comentarios por el tiempo que dure este post publicado o hasta que decidas borrar tu comentario. Legitimación: Tu consentimiento otorgado en este formulario. Destinatario: Wordpress.Derechos: Tienes derechos de acceso, rectificación, cancelación y oposición de tus datos. Este sitio usa Akismet para reducir el spam. Conoce cómo se procesan los datos de tus comentarios.

Ingenio Empresa