![]() |
Structure (or structs) in the C programming language provides a way to combine variables of several data types under one name and pointers provide a means of storing memory addresses. In this article, we will learn how to declare such a pointer to a struct in C. Declaration of Pointer to Struct in CTo declare a pointer to a struct we can use the struct keyword. First, define a structure then declare a pointer to that structure using the below syntax and that pointer can be used to allocate and access memory for the structure. Syntax of Declaring Pointer to Structstruct StructName *ptr ; C Program to Declare Pointer to StructThe below example demonstrates declaration of pointer to a structure. C++
Output
Coordinates: (10, 20) To know more, refer to the article – Structure Pointer in C |
Reffered: https://www.geeksforgeeks.org
C Language |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |