Structure Types
(part-II)
Ms. Mamoona Tasadduq
:
Slides: CS Deptt. Sharif University of Technology
Edited By: Dr. M. Aksam Iftikhar, CUI Lahore
, Input and Output – Lecture 4
Lecture Outline
• Pointers and struct variables
– Pointer to struct
– Dereferring the pointer
• The arrow operator
– Self-referential structure
• Functions and struct variables
– Passing struct variables to function
• Pass-by-value
• Pass-by-reference
– Returning struct variables from function
• Scope of struct definition
2
,Input and Output – Lecture 4
Pointer and Structure
3
, Input and Output – Lecture 4
Pointer to struct: Definition
⮚A variable of struct type is also a variable.
⮚It has address, so we can have pointer to it.
struct std{
int id;
grade;
int
}; std st1;
struct std
*ps;
ps = &st1;
4
struct