How to Pass Array of Structure to a Function in C? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report 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, functionName is the name of the function.structName is the name of the struct.*arrayName is a pointer to the array of structures.arraySize is the size of an array of structures.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. C // C Program to pass array of structures to a function #include <stdio.h> // Defining the struct struct MyStruct { int id; char name[20]; }; // Function to print the array of structures void printStructs(struct MyStruct* array, int size) { for (int i = 0; i < size; i++) { printf("Struct at index %d: ID = %d, Name = %s\n", i, array[i].id, array[i].name); } } int main() { // Declaring an array of structs struct MyStruct myArray[] = { { 1, "P1" }, { 2, "P2" }, }; // Passing the array of structures to the function printStructs(myArray, 2); return 0; } OutputStruct at index 0: ID = 1, Name = P1 Struct at index 1: ID = 2, Name = P2 Create Quiz Comment R riyarjha Follow 1 Improve R riyarjha Follow 1 Improve Article Tags : C Programs C Language C-Arrays C-Functions C Examples +1 More Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C3 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C5 min readArrays & StringsArrays in C4 min readStrings in C5 min readPointers and StructuresPointers in C7 min readFunction Pointer in C5 min readUnions in C3 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read Like