Buy book Online -

Slides:



Advertisements
Similar presentations
Incomplete Structs struct B; struct A { struct B * partner; // other declarations… }; struct B { struct A * partner; // other declarations… };
Advertisements

C Language.
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
Pointer to Structure. Structure variable can be access using pointers int a=10,*p; Here p  is an integer type pointer variable, p can hold the address.
Structures Spring 2013Programming and Data Structure1.
Structures in C.
What are Pointers? Different from other normal variables which can store values. pointers are special variables that can hold the address of a variable.
ARRAYS In this Lecture, we will try to develop understanding of some of the relatively complex concepts. The following are explained in this lecture with.
Structs. Structures We already know that arrays are many variables of the same type grouped together under the same name. Structures are like arrays except.
POINTERS. 1.a) POINTER EXPRESSIONS Pointer variables can be used in expression If p1 and p2 are properly declared and initialized pointers then following.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Welcome to Concepts Pointer Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्जेण्डर )PGT(CS) KV JHAGRAKHAND.
Welcome to Concepts of Pointers. Prepared by:- Sumit Kumar PGT(Computer Science) Kv,Samba.
© Oxford University Press All rights reserved. CHAPTER 7 POINTERS.
DATA STRUCTURE & ALGORITHMS Pointers & Structure.
 Memory setup  Pointer declaration  Address operator  Indirection  Printing addresses or pointers.
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 7 – Pointers.
POINTERS IN C Pointer Basics, Pointer Arithmetic, Pointer to arrays and Pointer in functions.
STRUCTURES. INTRODUCTION A structure is same as that of records. It stores related information about an entity. Structure is basically a user defined.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
Lecture 10: Structures. Outline Introduction Structure Definitions and declarations Initializing Structures Operations on Structures members Structures.
Pointers What is the data type of pointer variables?
EGR 2261 Unit 11 Pointers and Dynamic Variables
Chapter 8 Arrays, Strings and Pointers
Introduction to Programming Using C
CSC215 Lecture Advanced Pointers.
BILASPUR UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE AND APPLICATION
Functions and Pointers
Chapter 10-1: Structure.
Lecture 7 Arrays 1. Concept of arrays Array and pointers
CHP-2 ARRAYS.
LESSON 3 IO, Variables and Operators
Student Book An Introduction
Visit for more Learning Resources
Module 2 Arrays and strings – example programs.
Pointers.
Functions and Pointers
Basic notes on pointers in C
DATA HANDLING.
Tejalal Choudhary “C Programming from Scratch” Pointers
Visit for more Learning Resources
Buy book Online -
Pointers and References
Lecture 9 Structure 1. Concepts of structure Pointers of structures
Chapter 5 POINTERs.
Pointers  Week 10.
Pointer to Structures Lesson xx
Structures Department of Computer Engineering
5th Chapter Pointers in C++.
Dr Tripty Singh Arrays.
C Programming Lecture-8 Pointers and Memory Management
C Programming Lecture-13 Structures
Structures In C Programming By Rajanikanth B.
POINTER CONCEPT 4/15/2019.
C Programming Pointers
Chapter 9: Pointers and String
The Pointers of Structures
A simple function.
Pointers and dynamic objects
CSCE 206 Lab Structured Programming in C
CS31 Discussion 1H Fall18: week 7
Course Outcomes of Programming In C (PIC) (17212, C203):
Chapter 5 POINTERs Visit to more Learning Resources.
POINTER CONCEPT 8/3/2019.
Structures, Unions, and Enumerations
Arrays and Pointers.
Introduction to Pointers
Introduction to Pointers
Visit for more Learning Resources
Presentation transcript:

Buy book Online - www.icebreakerspublications.com

Under st anding Pointe r Definition : Variable store the values. E.g. int i store 5. Pointer is a variable which store address of another variable. E.g. j store address of i , so j is a pointer. Buy book Online - www.icebreakerspublications.com

Pointer Declaration <data type> * <pointer name> int * ptr Syntax : <data type> * <pointer name> Example : int * ptr Buy book Online - www.icebreakerspublications.com

Store Address to pointer Syntax : Pointer-name = & (variable name) Example : j = & i; Buy book Online - www.icebreakerspublications.com

Accessing Pointer * pointer-name *j Syntax : Example : Buy book Online - www.icebreakerspublications.com

Example : Pointer #include<stdio.h> #include<conio.h> int main() { int number =0; int *ptr; printf(“\n Enter number”); scanf(“%d”, &number); Output: Enter number 5 5 is stored at 65524 ptr=&number; //assigning address of number to pointer ptr printf(“\n %d is stored at %u ”, number , ptr); // printing address using %u getch(); return 0; }

Pointer With Function (call by reference) #include<stdio.h> int add (int * , int *); //1. function declaration int * <--pointer int main() { int a=5 , b=6, y; y=Add(&a , &b); // 2. function call passing reference. printf(“addition = %d” , y); return 0; } int add (int * x, int * y) { // 3. function definition int result; result= *x + *y; // *x contain value 5 return result; } Output: addition =11

Pointer with Structure Syntax: Example: struct struct-name struct book { { ---- int price; ---- int pages; ---- char name[ 50 ]; }; }; struct struct-name * pointer-name ; struct book * ptr1; Buy book Online - www.icebreakerspublications.com

Exam ucture Example

Array of Pointers arr[0] = & i ; arr[1] = & j; arr[2] = & k; Definition : The way there can be an array of ints or an array of floats, similarly there can be an array of pointers. Since a pointer variable always contains an address, an array of pointers would be nothing but a collection of addresses. Example: int * arr[4] ; arr is array of integer pointers. It contains 4 addresses of integer variables: arr[0] = & i ; arr[1] = & j; arr[2] = & k; arr[3] = & l ; Buy book Online - www.icebreakerspublications.com

Pointe r To Pointe r int i , *j , **k ; int i =30 int *j = &i Observe how the variables j and k have been declared, int i , *j , **k ; Here, i is an ordinary int, j is a pointer to an int (often called an integer pointer), whereas k is a pointer to an integer pointer (often called a pointer to pointer). variable pointer pointer to pointer int i =30 int *j = &i int **k = &j Buy book Online - www.icebreakerspublications.com

End of chapter