In this program, you will learn to use an arrow operator. An Arrow operator in C/C++ allows to access elements in Structures and Unions. It is used with a pointer variable pointing to a structure or union. The arrow operator is formed by using a minus sign, followed by the greater than symbol (->).
#include <stdio.h>
struct student
{
char name[20];
int rollno;
};
void main()
{
struct student s = {"Prakash", 34};
struct student *ptr;
ptr = &s;
printf("NAME: %s\n", ptr->name);
printf("ROLL NO: %d\n", ptr->rollno);
getch();
}
NAME: Prakash
ROLL NO: 34