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.

Slides:



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

EC-211 DATA STRUCTURES LECTURE 2. EXISTING DATA STRUCTURES IN C/C++ ARRAYS – A 1-D array is a finite, ordered set of homogeneous elements – E.g. int a[100]
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
Pointer Variables The normal variables hold values. For example, int j; j = 2; Then a reference to j in an expression will be identified with the value.
Data Structures (Second Part) Lecture 2 : Pointers Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
Introduction to Programming Lecture 39. Copy Constructor.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Pointers & Dynamic Memory Allocation Mugurel Ionu Andreica Spring 2012.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
1 Pointers A pointer variable holds an address We may add or subtract an integer to get a different address. Adding an integer k to a pointer p with base.
Modular Programming (2) H&K Chapter 6 Instructor – Gokcen Cilingir Cpt S 121 (July 8, 2011) Washington State University.
ECE 353: Lab C Pointers and Structs. Basics A pointer holds an address to some variable Notation: – Dereferencing operator: * int *x is a declaration.
Pointers Pointer - A pointer is a derived data type; that is it is a data type built from one of the standard types. Its value is any of the addresses.
Pointers. COMP104 Pointers / Slide 2 Pointers * A pointer is a variable used for storing the address of a memory cell. * We can use the pointer to reference.
Pointers Example Use int main() { int *x; int y; int z; y = 10; x = &y; y = 11; *x = 12; z = 15; x = &z; *x = 5; z = 8; printf(“%d %d %d\n”, *x, y, z);
Pointers| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: September 2006 Slide 1 Pointers by Jumail Bin Taliba Faculty of Computer.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
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.
Data Objects (revisited) Recall that values are stored in data objects, and that each data object holds one value of a particular type. Data objects may.
CS-1030 Dr. Mark L. Hornick 1 Pointers are fun!
Array, Structure and Union
Defining a 2d Array A 2d array implements a MATRIX. Example: #define NUMROWS 5 #define NUMCOLS 10 int arr[NUMROWS][NUMCOLS];
C++ Pointers Review. Overview  What is a pointer  Why do I care?  What can be 'pointed to'?  Example.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Passing Structure to function.  structure to function structure to function  Passing structure to function in C Passing structure to function in C 
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.
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
1 Homework / Exam Finishing K&R Chapter 5 today –Skipping sections for now –Not covering section 5.12 Starting K&R Chapter 6 next Continue HW5.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Pointers PART - 2. Pointers Pointers are variables that contain memory addresses as their values. A variable name directly references a value. A pointer.
Week 12 Methods for passing actual parameters to formal parameters.
POINTERS IN C. Introduction  A pointer is a variable that holds a memory address  This address is the location of another object (typically another.
Pointer Lecture 2 Course Name: High Level Programming Language Year : 2010.
Introduction to CMex E177 April 25, Copyright 2005, Andy Packard. This work is licensed under the Creative.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
Pointers as arrays C++ Programming Technologies. Pointers vs. Arrays Pointers and arrays are strongly related. In fact, pointers and arrays are interchangeable.
Prepared by Andrew Jung. Accessing Pointer Data Pointer can be used to access the contents of an array Look at the following syntax: /* Declaration and.
Basic Concepts:- Invalid use of Address Operator &75 &(‘a’) &(a+b)
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Instructions for test_function
Introduction to Programming Using C
Pointers in C.
Pointers and Pointer-Based Strings
Visit for more Learning Resources
Programming Languages and Paradigms
INC 161 , CPE 100 Computer Programming
Basic notes on pointers in C
Variables ,Data Types and Constants
Tejalal Choudhary “C Programming from Scratch” Pointers
Buy book Online -
Lecture 9 Structure 1. Concepts of structure Pointers of structures
LINKED LISTS.
S. Kiran, PGT (CS) KV, Malleswaram
Pointer to a Structure & Structure Containing a Pointer Difference Lesson xx  In this presentation, we will illustrate the difference between a pointer.
Structure ការណែនាំអំពី Structure
بنام خدا زبان برنامه نویسی C (21814( Lecture 11 Pointers
Pointer to Structures Lesson xx
Parameter Passing in Java
Pointers and Pointer-Based Strings
ECE 103 Engineering Programming Chapter 35 C Pointers, Part 1
C Programming Lecture-8 Pointers and Memory Management
C Programming Pointers
The Stack.
CS31 Discussion 1H Fall18: week 7
CSCE 206 Lab Structured Programming in C
Arrays and Pointers CSE 2031 Fall July 2019.
Files Chapter 8.
Introduction to Pointers
Presentation transcript:

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 of an integer(a) ie p=&a; in order to access the content of a  *p ie ‘a’ can be access using the pointer variable p Like that a structure variable can be access using a pointer variable

Pointer to Structure let struct student { char name[20]; int m1,m2,m3,total }; struct student s, *p; Now ‘s’  is the variable of type struct student ‘p’  is a pointer variable of type struct student Since p and s are same type, p can store the address of the variable s Ie p=&s; Now the content of p is address of s

Pointer to Structure The structure variable s can be access using p With the help of point to operator (->) ie p->name equalant to s.name p->m1 equalant to s.m1 p->m2 equalant to s.m2 p->m3 equalant to s.m3 p->total equalant to s.total

Pointer to Structure void main() { struct check { int a; char c[20]; }; struct check s,*p; p=&s; scanf("%d%s",&p->a,p->c); printf("%d %s",p->a,p->c); getch(); }