Professional Documents
Culture Documents
Arrow Operator - in C - C++ With Examples - GeeksforGeeks
Arrow Operator - in C - C++ With Examples - GeeksforGeeks
Arrow Operator - in C - C++ With Examples - GeeksforGeeks
es
Arrow operator -> in C/C++ with Examples
An Arrow operator in C/C++ allows to access elements in Structures and Unions. It is used with a pointer
Custom Search
variable pointing to a structure or union. The arrow operator is formed by using a minus sign, followed by
(pointer_name)->(variable_name)
Operation: The -> operator in C or C++ gives the value held by variable_name to structure or union variable
pointer_name.
Examples:
#include <stdio.h>
#include <stdlib.h>
// Driver code
int main()
{
// Assigning memory to struct variable emp
emp = (struct student*)
malloc(sizeof(struct student));
return 0;
}
Output:
18
#include <stdio.h>
#include <stdlib.h>
// Driver code
int main()
{
// Assigning memory to struct variable emp
emp = (union student*)
malloc(sizeof(union student));
Output:
18
Recommended Posts:
Logical Not ! operator in C with Examples
dot (.) operator in C/C++
Like Operator in SAS Programming
sizeof operator in C
Conditional or Ternary Operator (?:) in C/C++
C++ | Operator Overloading | Question 7
C++ | Operator Overloading | Question 10
C++ | Operator Overloading | Question 9
C++ | Operator Overloading | Question 10
C++ | Operator Overloading | Question 6
C++ | Operator Overloading | Question 5
C++ | Operator Overloading | Question 4
C++ | Operator Overloading | Question 10
C++ | Operator Overloading | Question 2
C++ | Operator Overloading | Question 3
avsadityavardhan
Intern at GeeksforGeeks
If you like GeeksforGeeks and would like to contribute, you can also write an article using
contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article
appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you nd anything incorrect by clicking on the "Improve Article" button below.
⇣
Practice Tags : C
2
1
To-do Done
Based on 2 vote(s)
Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Load Comments
COMPANY LEARN
About Us Algorithms
Careers Data Structures
Privacy Policy Languages
Contact Us CS Subjects
Video Tutorials
PRACTICE CONTRIBUTE
Courses Write an Article
Company-wise Write Interview Experience
Topic-wise Internships
How to begin? Videos