## Table of contents

- Introduction
- Example number 1:
- Propose a data structure using only static variables to manage the students of a class
- Propose a data structure using only dynamic variables to manage the students of a class
- Calculate the memory space using the two methodes for a class of 20 students
- For Method number 1 (Using Static Variables) :
- For Method number 2 :
- Memory space allocation using the for as loop
- assignment of variables

- Pointer operations: real machine
- Comparison between pointers:
- Point a simple variable that already exists (statistic variable )
- Point -an-array
- Exemple
- Conclusion

# Introduction

In this article, I will further explain the concept of pointers (data structure) with some examples to practice what we have mentioned in the last article(part 1). To understand this concept you should check first the article Parte one and welcome back to train with me.

## Example number 1:

We assume that we have a class of 50 students and each person is defined by:

- His code,
- His family name [ max = 20 character];
- His name [ max = 20 character];

### Propose a data structure using only static variables to manage the students of a class

### Propose a data structure using only dynamic variables to manage the students of a class

### Calculate the memory space using the two methodes for a class of 20 students

- Method One : (2+20+20)*50 =2100 bytes

Since we use here *static variables*,
So if we need to calculate the memory area for one student is always equal to the storage space for 50 students, so the result will be always 2100 bytes

*While the second method, the mechanism is different*

S= 50+(2+20+20)*20 = 8900 bytes

Since we use here pointers we consume just the requested memory size, 50: Is the size of the pointer array, since they announced that each pointer occupies one byte

### For Method number 1 (Using Static Variables) :

Waste and mismanagement of data since static variables occupy memory until the end of execution.

### For Method number 2 :

Better optimization of memory space since dynamic variables can be created and deleted at any time

### Memory space allocation using the for as loop

### assignment of variables

# Pointer operations: real machine

### addition / subtraction of pointers

# Comparison between pointers:

the C language allows us to compare pointers using

== , != ,< ,>,<=,>= , null

# Point a simple variable that already exists (statistic variable )

# Point -an-array

We suppose T is an array of integers and P is a pointer to an integer

# Exemple

# Conclusion

These are the most popular instructions that you will need to use pointers and to build a solid basis in this domain I hope that you found my article useful, I did my best to clarify the idea and present it in a simple way