# Your Next Step With Pointers

# 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 ](https://hashnode.com/post/your-first-step-with-pointers-ckzhoxryx0ryylws1be2e0neb)  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:
1. His code,
2. His family name [ max = 20 character]; 
3. His name [ max = 20 character]; 

### Propose a data structure using only static variables to manage the students of a class
![d1.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657063534206/hE_fNS7g3.PNG align="left")
### Propose a data structure using only dynamic  variables to manage the students of a class

![d2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657063630082/9OfD5UVg-.PNG align="left")
### Calculate the memory space using the two methodes  for a class of 20 students

1. 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

![Vignette de Vlog YouTube Scolaire Geeky Violet Blanc et Bleu Clair (1).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657065005463/EigAcRbum.png align="left")

###  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 


![d3.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657065793797/o900Cnprj.PNG align="left")

### assignment of variables

![d4.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657065860901/VO56x0veD.PNG align="left")



# Pointer operations: real machine 
###  addition / subtraction of pointers 


![d5.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657065919966/ziL8Twy3n.PNG align="left")

# Comparison between pointers:

the C language allows us to compare pointers using

== , != ,< ,>,<=,>= , null 
# Point  a simple variable that already exists (statistic variable )

![d7.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657066107468/jfgo-EpeP.PNG align="left")

# Point -an-array

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

![d8.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657066159241/LeynoLuO9.PNG align="left")

# Exemple


![d10.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1657066329559/d1CoRn3sS.PNG align="left")
 # 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


