TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

DS Pointer

DS Pointer with Introduction, Asymptotic Analysis, Array, Pointer, Structure, Singly Linked List, Doubly Linked List, Circular Linked List, Binary Search, Linear Search, Sorting, Bucket Sort, Comb Sort, Shell Sort, Heap Sort, Merge Sort, Selection Sort, Counting Sort, Stack, Qene, Circular Quene, Graph, Tree, B Tree, B+ Tree, Avl Tree etc.

<< Back to DATA

Pointer

Pointer is used to points the address of the value stored anywhere in the computer memory. To obtain the value stored at the location is known as dereferencing the pointer. Pointer improves the performance for repetitive process such as:

  • Traversing String
  • Lookup Tables
  • Control Tables
  • Tree Structures
DS Pointer Performance

Pointer Details

  • Pointer arithmetic: There are four arithmetic operators that can be used in pointers: ++, --, +, -
  • Array of pointers: You can define arrays to hold a number of pointers.
  • Pointer to pointer: C allows you to have pointer on a pointer and so on.
  • Passing pointers to functions in C: Passing an argument by reference or by address enable the passed argument to be changed in the calling function by the called function.
  • Return pointer from functions in C: C allows a function to return a pointer to the local variable, static variable and dynamically allocated memory as well.
DS Pointer

Program

Pointer

#include <stdio.h>

int main( )
{
int a = 5;
int *b;
b = &a;

printf ("value of a = %d\n", a);
printf ("value of a = %d\n", *(&a));
printf ("value of a = %d\n", *b);
printf ("address of a = %u\n", &a);
printf ("address of a = %d\n", b);
printf ("address of b = %u\n", &b);
printf ("value of b = address of a = %u", b);
return 0;
}

Output

value of a = 5                                                                                                                 
value of a = 5                                                                                                                 
address of a = 3010494292                                                                                                      
address of a = -1284473004                                                                                                     
address of b = 3010494296                                                                                                      
value of b = address of a = 3010494292

Program

Pointer to Pointer

#include <stdio.h>

int main( )
{
int a = 5;
int *b;
int **c;
b = &a;
c = &b;
printf ("value of a = %d\n", a);
printf ("value of a = %d\n", *(&a));
printf ("value of a = %d\n", *b);
printf ("value of a = %d\n", **c);
printf ("value of b = address of a = %u\n", b);
printf ("value of c = address of b = %u\n", c);
printf ("address of a = %u\n", &a);
printf ("address of a = %u\n", b);
printf ("address of a = %u\n", *c);
printf ("address of b = %u\n", &b);
printf ("address of b = %u\n", c);
printf ("address of c = %u\n", &c);
return 0;
}

Pointer to Pointer

value of a = 5                                                                                                                 
value of a = 5                                                                                                                 
value of a = 5                                                                                                                 
value of a = 5                                                                                                                 
value of b = address of a = 2831685116                                                                                         
value of c = address of b = 2831685120
address of a = 2831685116                                                                                                      
address of a = 2831685116                                                                                                      
address of a = 2831685116                                                                                                      
address of b = 2831685120                                                                                                      
address of b = 2831685120                                                                                                      
address of c = 2831685128   
Next TopicDS Structure




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf