βΉοΈ 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.6 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://shahinur.com/en/use-of-arrow-operator-in-c-c/ |
| Last Crawled | 2026-03-31 13:54:33 (17 days ago) |
| First Indexed | 2024-04-21 19:24:36 (1 year ago) |
| HTTP Status Code | 200 |
| Meta Title | Use of arrow (β->β) operator in C/C++ |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Array operators are used extensively in most large programs. But why is this arrow used? Or what is the reason for using it?
It is basically an access operator. Variables can be declared both at compile time and at run time in C/C++. The way we usually declare variables is to allocate memory at compile time. And pointers are used to dynamically allocate memory at run time. The arrow operator (β->β) is used to access any member of a Struct, Union or Class of this pointer type. In general, members are accessed using the dot (.) operator. Now we see two examples, one with pointers and one without pointers β
#include iostream
using namespace std;
struct student{
int roll;
char *name;
};
int main()
{
student std;
std.roll=100120;
std.name="Shahinur";
cout<<std.roll<<endl<<std.name;
return 0;
}
The code used above uses the dot operator. Letβs look at the following program using pointers in exactly the same way β
#include iostream
using namespace std;
struct student{
int roll;
char *name;
};
int main()
{
student std, *stdptr;
stdptr=&std; // Assigning an address to the pointer
std.roll=100120;
std.name="Shahinur";
cout<<std.roll<<endl<<std.name<<endl; // Using . operator
cout<<stdptr->roll<<endl<stdptr->name; // Using arrow operator
return 0;
}
The above code uses the arrow operator to show how it can work with pointers as references.
0
0
votes
Article Rating |
| Markdown | [](https://shahinur.com/en/)
- [Home](https://shahinur.com/en)
- [Python Programming](https://shahinur.com/en/python-programming/)
- [Artificial Intelligence](https://shahinur.com/en/artificial-intelligence/)
- [Research](https://shahinur.com/en/research/)
- [About Shahinur](https://shahinur.com/en/dr-shahinur-alam/)
- [Air-Writing Datsets](https://shahinur.com/en/use-of-arrow-operator-in-c-c/)
- [RTD Dataset](https://shahinur.com/en/rtd/)
- [RTC Dataset](https://shahinur.com/en/rtc/)
- [Blog](https://shahinur.com/en/blog/)
- [বাΰ¦ΰ¦²ΰ¦Ύ](https://shahinur.com/bn/%E0%A6%B8%E0%A6%BF-%E0%A6%B8%E0%A6%BF-%E0%A6%8F-%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%B0%E0%A7%8B-%E0%A6%85%E0%A6%AA%E0%A6%BE%E0%A6%B0%E0%A7%87%E0%A6%9F%E0%A6%B0%E0%A7%87%E0%A6%B0/)
# Use of arrow (β-\>β) operator in C/C++
by [Shahinur](https://shahinur.com/en/author/shahinur/ "Posts by Shahinur") \| Apr 23, 2015 \| [C](https://shahinur.com/en/category/c/), [C++](https://shahinur.com/en/category/c-plus-plus/) \| [0 comments](https://shahinur.com/en/use-of-arrow-operator-in-c-c/#respond)

Array operators are used extensively in most large programs. But why is this arrow used? Or what is the reason for using it?
It is basically an access operator. Variables can be declared both at compile time and at run time in C/C++. The way we usually declare variables is to allocate memory at compile time. And pointers are used to dynamically allocate memory at run time. The arrow operator (β-\>β) is used to access any member of a Struct, Union or Class of this pointer type. In general, members are accessed using the dot (.) operator. Now we see two examples, one with pointers and one without pointers β
```
#include iostream
using namespace std;
struct student{
int roll;
char *name;
};
int main()
{
student std;
std.roll=100120;
std.name="Shahinur";
cout<<std.roll<<endl<<std.name;
return 0;
}
```
The code used above uses the dot operator. Letβs look at the following program using pointers in exactly the same way β
```
#include iostream
using namespace std;
struct student{
int roll;
char *name;
};
int main()
{
student std, *stdptr;
stdptr=&std; // Assigning an address to the pointer
std.roll=100120;
std.name="Shahinur";
cout<<std.roll<<endl<<std.name<<endl; // Using . operator
cout<<stdptr->roll<<endl<stdptr->name; // Using arrow operator
return 0;
}
```
The above code uses the arrow operator to show how it can work with pointers as references.
0 0 votes
Article Rating
### *Related*
### Leave a Reply[Cancel reply](https://shahinur.com/en/use-of-arrow-operator-in-c-c/#respond)
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
#### Recent Comments
#### Categories
- [Algorithm](https://shahinur.com/en/category/algorithm/) (3)
- [Artificial Intelligence](https://shahinur.com/en/category/artificial-intelligence/) (2)
- [Basic Terminology](https://shahinur.com/en/category/basic-terminology/) (4)
- [C](https://shahinur.com/en/category/c/) (5)
- [C++](https://shahinur.com/en/category/c-plus-plus/) (5)
- [Computer Vision](https://shahinur.com/en/category/computer-vision/) (2)
- [Data Structure](https://shahinur.com/en/category/data-structure/) (5)
- [Deep Learning](https://shahinur.com/en/category/deep-learning/) (8)
- [Game Development](https://shahinur.com/en/category/game-development/) (1)
- [Machine Learning](https://shahinur.com/en/category/machine-learning/) (8)
- [Mathematics](https://shahinur.com/en/category/mathematics/) (2)
- [Matplotlib](https://shahinur.com/en/category/matplotlib/) (2)
- [MediaPipe](https://shahinur.com/en/category/mediapipe/) (1)
- [Miscellaneous](https://shahinur.com/en/category/miscellaneous/) (11)
- [OpenCV](https://shahinur.com/en/category/opencv/) (2)
- [Optimization](https://shahinur.com/en/category/optimization/) (3)
- [Pandas](https://shahinur.com/en/category/pandas/) (1)
- [Python](https://shahinur.com/en/category/python/) (39)
- [Reinforcement Learning](https://shahinur.com/en/category/reinforcement-learning/) (3)
- [Unreal Engine](https://shahinur.com/en/category/unreal-engine/) (1)
- [Virtual Reality](https://shahinur.com/en/category/virtual-reality/) (1)
All right researved Β© [Shahinur](https://shahinur.com/)
- [Follow](https://www.facebook.com/Shahinur.Me/ "Follow on Facebook")
- [Follow](https://x.com/DrShahinurAlam "Follow on X")
- [Follow](https://github.com/shahinur-alam "Follow on GitHub")
- [Follow](https://scholar.google.com/citations?user=vL_AnyYAAAAJ&hl=en "Follow on Google")
wpDiscuz
0
0
Would love your thoughts, please comment.[x](https://shahinur.com/en/use-of-arrow-operator-in-c-c/)
()
[x](https://shahinur.com/en/use-of-arrow-operator-in-c-c/)
\| [Reply](https://shahinur.com/en/use-of-arrow-operator-in-c-c/)
Insert |
| Readable Markdown | Array operators are used extensively in most large programs. But why is this arrow used? Or what is the reason for using it?
It is basically an access operator. Variables can be declared both at compile time and at run time in C/C++. The way we usually declare variables is to allocate memory at compile time. And pointers are used to dynamically allocate memory at run time. The arrow operator (β-\>β) is used to access any member of a Struct, Union or Class of this pointer type. In general, members are accessed using the dot (.) operator. Now we see two examples, one with pointers and one without pointers β
```
#include iostream
using namespace std;
struct student{
int roll;
char *name;
};
int main()
{
student std;
std.roll=100120;
std.name="Shahinur";
cout<<std.roll<<endl<<std.name;
return 0;
}
```
The code used above uses the dot operator. Letβs look at the following program using pointers in exactly the same way β
```
#include iostream
using namespace std;
struct student{
int roll;
char *name;
};
int main()
{
student std, *stdptr;
stdptr=&std; // Assigning an address to the pointer
std.roll=100120;
std.name="Shahinur";
cout<<std.roll<<endl<<std.name<<endl; // Using . operator
cout<<stdptr->roll<<endl<stdptr->name; // Using arrow operator
return 0;
}
```
The above code uses the arrow operator to show how it can work with pointers as references.
0 0 votes
Article Rating |
| Shard | 167 (laksa) |
| Root Hash | 9368966089271834967 |
| Unparsed URL | com,shahinur!/en/use-of-arrow-operator-in-c-c/ s443 |