ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.1 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.geeksforgeeks.org/c/arrow-operator-in-c-c-with-examples/ |
| Last Crawled | 2026-04-12 09:11:23 (2 days ago) |
| First Indexed | 2025-06-13 18:57:44 (10 months ago) |
| HTTP Status Code | 200 |
| Meta Title | Arrow operator -> in C/C++ with Examples - GeeksforGeeks |
| Meta Description | Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more., Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. |
| Meta Canonical | null |
| Boilerpipe Text | Last Updated :
12 Jul, 2025
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 as shown below.
Syntax:
(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.
Difference between Dot(.) and Arrow(->) operator:
The Dot(.) operator is used to normally access members of a structure or union.
The Arrow(->) operator exists to access the members of the structure or the unions using pointers.
Examples:
Arrow operator in structure:
C
C++
JavaScript
Output:
18
Time complexity: O(1).
Auxiliary space: O(n). // n is the size of memory that is being dynamically allocated using the malloc function to store the structure student. The amount of memory used is proportional to the size of the structure and the number
Arrow operator in unions:
C++
C
Output:
18 |
| Markdown | [](https://www.geeksforgeeks.org/)

- Sign In
- [Courses]()
- [Tutorials]()
- [Interview Prep]()
- [C Tutorial](https://www.geeksforgeeks.org/c/c-programming-language/)
- [Interview Questions](https://www.geeksforgeeks.org/c/c-coding-interview-questions/)
- [Examples](https://www.geeksforgeeks.org/c/c-programming-examples/)
- [Quizzes](https://www.geeksforgeeks.org/c/c-multiple-choice-questions/)
- [Projects](https://www.geeksforgeeks.org/c/c-projects/)
- [Cheatsheet](https://www.geeksforgeeks.org/c/c-cheatsheet/)
- [File Handling](https://www.geeksforgeeks.org/c/basics-file-handling-c/)
- [Multithreading](https://www.geeksforgeeks.org/c/multithreading-in-c/)
- [Memory Layout](https://www.geeksforgeeks.org/c/memory-layout-of-c-program/)
- [DSA in C](https://www.geeksforgeeks.org/c/learn-dsa-in-c/)
# Arrow operator -\> in C/C++ with Examples
Last Updated : 12 Jul, 2025
An **Arrow operator in C/C++** allows to access elements in [Structures](https://www.geeksforgeeks.org/cpp/structures-in-cpp/) and [Unions](https://www.geeksforgeeks.org/c/c-unions/). It is used with a [pointer variable pointing to a structure or union](https://www.geeksforgeeks.org/dsa/self-referential-structures/). The arrow operator is formed by using a minus sign, followed by the greater than symbol as shown below.
**Syntax:**
```
(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.
**Difference between Dot(.) and Arrow(-\>) operator:**
- The Dot(.) operator is used to normally access members of a structure or union.
- The Arrow(-\>) operator exists to access the members of the structure or the unions using pointers.
**Examples:**
- **Arrow operator in structure:**
C
``
```
// C program to show Arrow operator
```
```
// used in structure
```
```
```
```
#include <stdio.h>
```
```
#include <stdlib.h>
```
```
```
```
// Creating the structure
```
```
struct student {
```
```
char name[80];
```
```
int age;
```
```
float percentage;
```
```
};
```
```
```
```
// Creating the structure object
```
```
struct student* emp = NULL;
```
```
```
```
// Driver code
```
```
int main()
```
```
{
```
```
// Assigning memory to struct variable emp
```
```
emp = (struct student*)
```
```
malloc(sizeof(struct student));
```
```
```
```
// Assigning value to age variable
```
```
// of emp using arrow operator
```
```
emp->age = 18;
```
```
```
```
// Printing the assigned value to the variable
```
```
printf("%d", emp->age);
```
```
```
```
return 0;
```
```
}
```
C++
``
```
// Printing the assigned value to the variable
```
JavaScript
``
```
// JavaScript program to show Arrow operator used in structure
```
**Output:**
```
18
```
Time complexity: O(1).
Auxiliary space: O(n). // n is the size of memory that is being dynamically allocated using the malloc function to store the structure student. The amount of memory used is proportional to the size of the structure and the number
- **Arrow operator in unions:**
C++
``
```
// C++ program to show Arrow operator
```
```
// used in structure
```
```
#include <iostream>
```
```
using namespace std;
```
```
```
```
// Creating the union
```
```
union student {
```
```
char name[80];
```
```
int age;
```
```
float percentage;
```
```
};
```
```
```
```
// Creating the union object
```
```
union student* emp = NULL;
```
```
```
```
// Driver code
```
```
int main()
```
```
{
```
```
// Assigning memory to struct variable emp
```
```
emp = (union student*)
```
```
malloc(sizeof(union student));
```
```
```
```
// Assigning value to age variable
```
```
// of emp using arrow operator
```
```
emp->age = 18;
```
```
```
```
// DIsplaying the assigned value to the variable
```
```
cout <<""<< emp->age;
```
```
}
```
```
```
```
// This code is contributed by shivanisinghss2110
```
C
``
```
// DIsplaying the assigned value to the variable
```
**Output:**
```
18
```
Comment
[A](https://www.geeksforgeeks.org/user/avsadityavardhan/)
[avsadityavardhan](https://www.geeksforgeeks.org/user/avsadityavardhan/)
107
Article Tags:
Article Tags:
[C Programs](https://www.geeksforgeeks.org/category/programming-language/c/c-programs/)
[C Language](https://www.geeksforgeeks.org/category/programming-language/c/)
### Explore
[](https://www.geeksforgeeks.org/)

Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)

Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
[](https://geeksforgeeksapp.page.link/gfg-app)[](https://geeksforgeeksapp.page.link/gfg-app)
- Company
- [About Us](https://www.geeksforgeeks.org/about/)
- [Legal](https://www.geeksforgeeks.org/legal/)
- [Privacy Policy](https://www.geeksforgeeks.org/legal/privacy-policy/)
- [Contact Us](https://www.geeksforgeeks.org/about/contact-us/)
- [Advertise with us](https://www.geeksforgeeks.org/advertise-with-us/)
- [GFG Corporate Solution](https://www.geeksforgeeks.org/gfg-corporate-solution/)
- [Campus Training Program](https://www.geeksforgeeks.org/campus-training-program/)
- Explore
- [POTD](https://www.geeksforgeeks.org/problem-of-the-day)
- [Job-A-Thon](https://practice.geeksforgeeks.org/events/rec/job-a-thon/)
- [Blogs](https://www.geeksforgeeks.org/category/blogs/?type=recent)
- [Nation Skill Up](https://www.geeksforgeeks.org/nation-skill-up/)
- Tutorials
- [Programming Languages](https://www.geeksforgeeks.org/computer-science-fundamentals/programming-language-tutorials/)
- [DSA](https://www.geeksforgeeks.org/dsa/dsa-tutorial-learn-data-structures-and-algorithms/)
- [Web Technology](https://www.geeksforgeeks.org/web-tech/web-technology/)
- [AI, ML & Data Science](https://www.geeksforgeeks.org/machine-learning/ai-ml-and-data-science-tutorial-learn-ai-ml-and-data-science/)
- [DevOps](https://www.geeksforgeeks.org/devops/devops-tutorial/)
- [CS Core Subjects](https://www.geeksforgeeks.org/gate/gate-exam-tutorial/)
- [Interview Preparation](https://www.geeksforgeeks.org/aptitude/interview-corner/)
- [Software and Tools](https://www.geeksforgeeks.org/websites-apps/software-and-tools-a-to-z-list/)
- Courses
- [ML and Data Science](https://www.geeksforgeeks.org/courses/category/machine-learning-data-science)
- [DSA and Placements](https://www.geeksforgeeks.org/courses/category/dsa-placements)
- [Web Development](https://www.geeksforgeeks.org/courses/category/development-testing)
- [Programming Languages](https://www.geeksforgeeks.org/courses/category/programming-languages)
- [DevOps & Cloud](https://www.geeksforgeeks.org/courses/category/cloud-devops)
- [GATE](https://www.geeksforgeeks.org/courses/category/gate)
- [Trending Technologies](https://www.geeksforgeeks.org/courses/category/trending-technologies/)
- Videos
- [DSA](https://www.geeksforgeeks.org/videos/category/sde-sheet/)
- [Python](https://www.geeksforgeeks.org/videos/category/python/)
- [Java](https://www.geeksforgeeks.org/videos/category/java-w6y5f4/)
- [C++](https://www.geeksforgeeks.org/videos/category/c/)
- [Web Development](https://www.geeksforgeeks.org/videos/category/web-development/)
- [Data Science](https://www.geeksforgeeks.org/videos/category/data-science/)
- [CS Subjects](https://www.geeksforgeeks.org/videos/category/cs-subjects/)
- Preparation Corner
- [Interview Corner](https://www.geeksforgeeks.org/interview-prep/interview-corner/)
- [Aptitude](https://www.geeksforgeeks.org/aptitude/aptitude-questions-and-answers/)
- [Puzzles](https://www.geeksforgeeks.org/aptitude/puzzles/)
- [GfG 160](https://www.geeksforgeeks.org/courses/gfg-160-series)
- [System Design](https://www.geeksforgeeks.org/system-design/system-design-tutorial/)
[@GeeksforGeeks, Sanchhaya Education Private Limited](https://www.geeksforgeeks.org/), [All rights reserved](https://www.geeksforgeeks.org/copyright-information/)
![]() |
| Readable Markdown | Last Updated : 12 Jul, 2025
An **Arrow operator in C/C++** allows to access elements in [Structures](https://www.geeksforgeeks.org/cpp/structures-in-cpp/) and [Unions](https://www.geeksforgeeks.org/c/c-unions/). It is used with a [pointer variable pointing to a structure or union](https://www.geeksforgeeks.org/dsa/self-referential-structures/). The arrow operator is formed by using a minus sign, followed by the greater than symbol as shown below.
**Syntax:**
```
(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.
**Difference between Dot(.) and Arrow(-\>) operator:**
- The Dot(.) operator is used to normally access members of a structure or union.
- The Arrow(-\>) operator exists to access the members of the structure or the unions using pointers.
**Examples:**
- **Arrow operator in structure:**
C
C++
JavaScript
**Output:**
```
18
```
Time complexity: O(1).
Auxiliary space: O(n). // n is the size of memory that is being dynamically allocated using the malloc function to store the structure student. The amount of memory used is proportional to the size of the structure and the number
- **Arrow operator in unions:**
C++
C
**Output:**
```
18
``` |
| Shard | 103 (laksa) |
| Root Hash | 12046344915360636903 |
| Unparsed URL | org,geeksforgeeks!www,/c/arrow-operator-in-c-c-with-examples/ s443 |