 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to pass the address of structure as an argument to function in C language?
Passing the address of structure as an argument to function −
- The Address of the structure is passed as an argument to the function. 
- It is collected in a pointer to structure in function header. 
Advantages
- No wastage of memory as there is no need of creating a copy again 
- No need of returning the values back as the function can access indirectly the entire structure and work on it. 
Example
#include<stdio.h> struct date{    int day;    int mon;    int yr; }; main (){    struct date d= {02,01,2010};    display (&d);    getch (); } display (struct date *dt){    printf("day = %d
", dt->day);    printf("month = %d
",dt->mon);    printf("Year = %d",dt->yr); } Output
day = 2 month = 1 Year = 2010
Advertisements
 