![]() |
Union is a user-defined data type in C language that can contain elements of the different data types and pointers are used to store memory addresses. In this article, we will learn how to declare a pointer to a union in C++. Pointer to Union in CTo declare a pointer to a union first, define a union and then declare a pointer that points to the union type using the below syntax: Syntax to Declare Pointer to Union in C//Define Union We can also assign the pointer the address of some union variable by using the addressof(&) operator. C Program to Declare Pointer to UnionThe following programs show how to declare pointers to unions in C programming and access members using the arrow operator (->). C
Output
The intValue is: 100 The floatValue is: 3.140000 |
Reffered: https://www.geeksforgeeks.org
C Language |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |