Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Pointers to Pointers and Double Dereferencing in C, Exercises of Computer Fundamentals

An example of how to use pointers to pointers and double dereferencing in c programming language. It explains the concept with the help of a simple c program and demonstrates how to change the value of a variable using pointers to pointers.

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

karthik
karthik 🇮🇳

4.6

(17)

100 documents

1 / 1

Toggle sidebar

Related documents


Partial preview of the text

Download Understanding Pointers to Pointers and Double Dereferencing in C and more Exercises Computer Fundamentals in PDF only on Docsity! #include <stdlib.h> #include <stdio.h> /* * This program basically demonstrate how to use pointer to a pointer and * use of double dereference operator. */ int main (int argc, char *argv[]) { int i,a=0; int *ptr_a; // pointer to int int **ptr_ptr_a; // pointer to a pointer of type int //code to see double dereferencing. printf("Memory address of a is %p \n",&a); ptr_a=&a; // ptr_a points to variable a printf("ptr_a stores Memory address of a is %p\n",ptr_a); printf("Memory address of ptr is %p\n",&ptr_a); *ptr_a=5; // changing value of a using ptr_ptr_a printf("\n printing value using ptr_a a=%d \n",*ptr_a); ptr_ptr_a=&ptr_a; // ptr_ptr_a points to another pointer ptr_a printf("ptr_ptr_a stores Memory address of ptr_a is %p\n",ptr_ptr_a); printf("Memory address of ptr_ptr_a is %p\n",&ptr_ptr_a); **ptr_ptr_a=11; // changing value of a using ptr_ptr_a printf("\n printing value using ptr_ptr_a a=%d \n",**ptr_ptr_a); return 0; } docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved