Posted by : Shubham Pandey Friday, February 5



  Introduction to Data structure  

Data structure is a way to organized data in some way so that we can perform operations on the data in effective way.
Some examples are listed below.
    Image result for Data Structure  , C Programing
  • Link List.
  • Stack.
  • Queue.
  • Tree.
  • Graph.
  • Hash Table.
We select data structure according to need that is-
1) Size of data.
2) Amount of data.


For Implementing Data structure We need to understand Dynamic Memory Allocation 



Pointers - A pointer is  variable which contain the  memory address of another variable. 

 Declaration Of Pointer variable -

int a;  // Normal variable Declaration
int *a; // Pointer Variable Declaration

Operators Of Pointer -

  •  &  - Address Operator 
  •  *    - Value at the address operator 

Example of Pointer -

 #include<stdio.h> // Header files
Void main()
int a=5;
int  *p ;
p = &a ;
printf("\n %d",a);         // 5
printf("\n %d",p);         // address 25001
printf("\n %u",&a);      //25001
printf("\n %u",&a);      // 25002
printf("\n %d",*p);       // 5
printf("\n %d",*(&a));  // 5
return 0;

Dynamic Memory Allocation

Image result for Data Structure  , Dynamic Memory Allocation  , C Programing
The process allocating at the time of execution is called dynamic memory allocation. The allocation and releasing  of the memory space can be done with the use of some built in functions. 
  • sizeof() 
  • malloc()
  • calloc()
  • free()


 The size of operation is use to find the  size  of argument in terms of byte . the argument can be  variable or any data type.
int a[10] ;
sizeof(a);      // 20
sizeof(float); // 4 


This function is use to allocate the memory space.
Syntax - ptr =(data type *) malloc( specific size) ;
ptr =(int*) malloc(10) ;


This function is used to allocate the multiple blocks of memory.
syntax - ptr = (int*) calloc( number of block , size of block ) ;
ptr =(int*) calloc ( 5 , 2) ; // this allocate 5 blocks , each of 2 bytes 


This function is use to release the memory spaces.
Syntax - free(ptr);
free(ptr) ; // memory set to free 

we would like to have an interactive session. comment your questions below.

Be updated Be safe !

Cheers !!

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Popular Post

- Copyright © Technopits -Powered by Blogger