![]() |
An array of structures in C is a data structure that allows us to store multiple records of different data types in a contiguous memory location where each element of the array is a structure. In this article, we will learn how to pass an array of structures from one function to another in C. Passing an Array of Struct to Functions in CWe can pass an array of structures to a function in a similar way as we pass an array of any other data type i.e. by passing the array as the pointer to its first element. Syntax to Pass Array of Struct to Function in C// using array notation returnType functionName(struct structName arrayName[], dataType arraySize); // using pointer notation returnType functionName(struct structName *arrayName, dataType arraySize) ); Here,
C Program to Pass Array of Struct to FunctionThe below program demonstrates how we can pass an array of structures to a function in C.
Output Struct at index 0: ID = 1, Name = P1 Struct at index 1: ID = 2, Name = P2
|
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |