🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 169 (from laksa014)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
2 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c
Last Crawled2026-04-07 23:10:43 (2 days ago)
First Indexed2015-05-18 19:47:25 (10 years ago)
HTTP Status Code200
Meta Titlepointers - Arrow operator (->) usage in C - Stack Overflow
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
Well I have to add something as well. Structure is a bit different than array because array is a pointer and structure is not. So be careful! Lets say I write this useless piece of code: # include <stdio.h> typedef struct { int km; int kph; int kg; } car; int main ( void ) { car audi = { 12000 , 230 , 760 }; car *ptr = &audi; } Here pointer ptr points to the address ( ! ) of the structure variable audi but beside address structure also has a chunk of data ( ! )! The first member of the chunk of data has the same address than structure itself and you can get it's data by only dereferencing a pointer like this *ptr (no braces) . But If you want to acess any other member than the first one, you have to add a designator like .km , .kph , .kg which are nothing more than offsets to the base address of the chunk of data ... But because of the preceedence you can't write *ptr.kg as access operator . is evaluated before dereference operator * and you would get *(ptr.kg) which is not possible as pointer has no members! And compiler knows this and will therefore issue an error e.g.: error: ‘ptr’ is a pointer; did you mean to use ‘->’? printf ( "%d\n" , *ptr.km); Instead you use this (*ptr).kg and you force compiler to 1st dereference the pointer and enable acess to the chunk of data and 2nd you add an offset (designator) to choose the member. Check this image I made: But if you would have nested members this syntax would become unreadable and therefore -> was introduced. I think readability is the only justifiable reason for using it as this ptr->kg is much easier to write than (*ptr).kg . Now let us write this differently so that you see the connection more clearly. (*ptr).kg ⟹ (*&audi).kg ⟹ audi.kg . Here I first used the fact that ptr is an "address of audi " i.e. &audi and fact that "reference" & and "dereference" * operators cancel eachother out.
Markdown
# ![site logo](https://stackoverflow.com/Content/Img/SE-logo75.png) By clicking “Sign up”, you agree to our [terms of service](https://stackoverflow.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://stackoverflow.com/legal/privacy-policy). # OR Already have an account? [Log in](https://stackoverflow.com/users/login) [Skip to main content](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#content) 1. [About](https://stackoverflow.co/) 2. Products 3. [For Teams](https://stackoverflow.co/internal/) 4. Try new site Try BETA 1. [Stack Internal Implement a knowledge platform layer to power your enterprise and AI tools.](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) 2. [Stack Data Licensing Get access to top-class technical expertise with trusted & attributed content.](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) 3. [Stack Ads Connect your brand to the world’s most trusted technologist communities.](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) 4. [Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal.](https://stackoverflow.blog/releases/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=releases) 5. [About the company](https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) [Visit the blog](https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) 1. ### [current community](https://stackoverflow.com/) - [Stack Overflow](https://stackoverflow.com/) [help](https://stackoverflow.com/help) [chat](https://chat.stackoverflow.com/?tab=explore) - [Meta Stack Overflow](https://meta.stackoverflow.com/) ### your communities [Sign up](https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2575048%2Farrow-operator-usage-in-c) or [log in](https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2575048%2Farrow-operator-usage-in-c) to customize your list. ### [more stack exchange communities](https://stackexchange.com/sites) [company blog](https://stackoverflow.blog/) 2. [Log in](https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2575048%2Farrow-operator-usage-in-c) 3. [Sign up](https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2575048%2Farrow-operator-usage-in-c) How are we doing? Please help us improve Stack Overflow. [Take our short survey](https://stackoverflow.com/survey/site-satisfaction/redirect) # Let's set up your homepage Select a few topics you're interested in: python javascript c\# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: - javascript - python - java - c\# - php - android - html - jquery - c++ - css - ios - sql - mysql - r - reactjs - node.js - arrays - c - asp.net - json - python-3.x - .net - ruby-on-rails - sql-server - swift - django - angular - objective-c - excel - pandas - angularjs - regex - typescript - ruby - linux - ajax - iphone - vba - xml - laravel - spring - asp.net-mvc - database - wordpress - string - flutter - postgresql - mongodb - wpf - windows - xcode - amazon-web-services - bash - git - oracle-database - spring-boot - dataframe - azure - firebase - list - multithreading - docker - vb.net - react-native - eclipse - algorithm - powershell - macos - visual-studio - numpy - image - forms - scala - function - vue.js - performance - twitter-bootstrap - selenium - winforms - kotlin - loops - dart - express - sqlite - hibernate - matlab - python-2.7 - shell - rest - apache - entity-framework - android-studio - csv - maven - linq - qt - dictionary - unit-testing - asp.net-core - facebook - apache-spark - tensorflow - file - swing - class - unity-game-engine - sorting - date - authentication - go - symfony - t-sql - opencv - matplotlib - .htaccess - google-chrome - for-loop - datetime - codeigniter - perl - http - validation - sockets - google-maps - object - uitableview - xaml - oop - visual-studio-code - if-statement - cordova - ubuntu - web-services - email - android-layout - github - spring-mvc - elasticsearch - kubernetes - selenium-webdriver - ms-access - ggplot2 - parsing - user-interface - pointers - google-sheets - c++11 - security - machine-learning - google-apps-script - ruby-on-rails-3 - templates - flask - nginx - variables - exception - sql-server-2008 - gradle - debugging - tkinter - delphi - listview - jpa - asynchronous - haskell - web-scraping - jsp - pdf - ssl - amazon-s3 - google-cloud-platform - xamarin - testing - jenkins - wcf - batch-file - generics - npm - ionic-framework - network-programming - unix - recursion - google-app-engine - mongoose - visual-studio-2010 - .net-core - android-fragments - assembly - animation - math - rust - svg - session - intellij-idea - hadoop - join - winapi - curl - django-models - laravel-5 - url - next.js - heroku - http-redirect - tomcat - inheritance - google-cloud-firestore - webpack - gcc - swiftui - image-processing - keras - asp.net-mvc-4 - logging - dom - matrix - pyspark - actionscript-3 - button - post - optimization - firebase-realtime-database - cocoa - jquery-ui - xpath - iis - d3.js - web - javafx - firefox - xslt - internet-explorer - caching - select - asp.net-mvc-3 - opengl - events - asp.net-web-api - plot - dplyr - encryption - magento - stored-procedures - search - amazon-ec2 - ruby-on-rails-4 - memory - multidimensional-array - canvas - audio - random - jsf - vector - redux - cookies - input - facebook-graph-api - flash - indexing - xamarin.forms - arraylist - ipad - cocoa-touch - data-structures - video - model-view-controller - azure-devops - serialization - apache-kafka - jdbc - razor - awk - woocommerce - routes - mod-rewrite - servlets - excel-formula - beautifulsoup - filter - iframe - docker-compose - design-patterns - aws-lambda - text - visual-c++ - django-rest-framework - cakephp - mobile - android-intent - struct - react-hooks - methods - groovy - mvvm - lambda - ssh - time - checkbox - ecmascript-6 - grails - installation - google-chrome-extension - cmake - sharepoint - shiny - spring-security - jakarta-ee - plsql - android-recyclerview - core-data - types - sed - meteor - android-activity - bootstrap-4 - activerecord - replace - websocket - graph - group-by - scikit-learn - vim - file-upload - boost - junit - memory-management - sass - async-await - import - deep-learning - error-handling - eloquent - dynamic - dependency-injection - silverlight - soap - layout - apache-spark-sql - charts - deployment - browser - gridview - svn - while-loop - google-bigquery - vuejs2 - highcharts - dll - ffmpeg - view - foreach - makefile - plugins - redis - c\#-4.0 - reporting-services - jupyter-notebook - unicode - merge - reflection - https - server - google-maps-api-3 - twitter - oauth-2.0 - extjs - terminal - pip - axios - split - cmd - encoding - pytorch - django-views - collections - database-design - hash - automation - netbeans - ember.js - data-binding - build - tcp - pdo - apache-flex - sqlalchemy - entity-framework-core - concurrency - command-line - spring-data-jpa - printing - react-redux - java-8 - lua - html-table - neo4j - ansible - service - jestjs - enums - parameters - flexbox - promise - module - material-ui - visual-studio-2012 - outlook - mysqli - web-applications - uwp - webview - firebase-authentication - jquery-mobile - utf-8 - datatable - python-requests - parallel-processing - colors - drop-down-menu - scipy - tfs - scroll - hive - count - syntax - ms-word - twitter-bootstrap-3 - ssis - fonts - rxjs - constructor - file-io - google-analytics - paypal - three.js - powerbi - cassandra - graphql - discord - graphics - compiler-errors - gwt - react-router - socket.io - backbone.js - memory-leaks - solr - url-rewriting - datatables - nlp - terraform - oauth - datagridview - drupal - zend-framework - oracle11g - knockout.js - triggers - interface - neural-network - django-forms - casting - angular-material - jmeter - linked-list - google-api - path - timer - django-templates - arduino - orm - windows-phone-7 - directory - proxy - parse-platform - visual-studio-2015 - cron - conditional-statements - push-notification - functional-programming - primefaces - pagination - model - jar - xamarin.android - hyperlink - uiview - visual-studio-2013 - vbscript - google-cloud-functions - azure-active-directory - gitlab - jwt - download - swift3 - sql-server-2005 - rspec - pygame - process - configuration - properties - callback - combobox - windows-phone-8 - linux-kernel - safari - scrapy - emacs - permissions - x86 - clojure - scripting - raspberry-pi - io - scope - azure-functions - compilation - mongodb-query - responsive-design - nhibernate - expo - angularjs-directive - reference - architecture - binding - bluetooth - request - dns - playframework - 3d - version-control - pyqt - discord.js - doctrine-orm - package - f\# - rubygems - get - sql-server-2012 - tree - autocomplete - datepicker - kendo-ui - openssl - jackson - yii - controller - grep - nested - xamarin.ios - static - null - transactions - statistics - datagrid - active-directory - uiviewcontroller - dockerfile - webforms - sas - computer-vision - discord.py - phpmyadmin - notifications - duplicates - pycharm - youtube - mocking - nullpointerexception - yaml - menu - blazor - sum - plotly - bitmap - visual-studio-2008 - asp.net-mvc-5 - floating-point - yii2 - css-selectors - stl - android-listview - jsf-2 - electron - time-series - cryptography - ant - hashmap - character-encoding - msbuild - stream - asp.net-core-mvc - sdk - google-drive-api - jboss - selenium-chromedriver - joomla - devise - cuda - navigation - cors - frontend - anaconda - background - multiprocessing - binary - pyqt5 - camera - iterator - linq-to-sql - mariadb - onclick - ios7 - android-jetpack-compose - microsoft-graph-api - android-asynctask - rabbitmq - amazon-dynamodb - tabs - environment-variables - laravel-4 - uicollectionview - insert - linker - coldfusion - xsd - console - continuous-integration - upload - textview - ftp - opengl-es - macros - operating-system - mockito - localization - formatting - json.net - xml-parsing - type-conversion - data.table - vuejs3 - kivy - timestamp - integer - calendar - segmentation-fault - android-ndk - prolog - char - drag-and-drop - crash - jasmine - azure-pipelines - automated-tests - dependencies - geometry - fortran - android-gradle-plugin - itext - sprite-kit - mfc - header - attributes - nosql - format - firebase-cloud-messaging - nuxt.js - odoo - db2 - jquery-plugins - event-handling - julia - jenkins-pipeline - leaflet - annotations - flutter-layout - keyboard - nestjs - postman - arm - textbox - stripe-payments - visual-studio-2017 - gulp - libgdx - uikit - timezone - synchronization - azure-web-app-service - dom-events - wso2 - google-sheets-formula - xampp - crystal-reports - aggregation-framework - namespaces - android-emulator - uiscrollview - swagger - jvm - sequelize.js - com - chart.js - snowflake-cloud-data-platform - subprocess - html5-canvas - geolocation - garbage-collection - webdriver - sql-update - dialog - centos - concatenation - numbers - widget - qml - tuples - set - java-stream - mapreduce - ionic2 - smtp - android-edittext - windows-10 - nuget - rotation - modal-dialog - spring-data - radio-button - doctrine - http-headers - grid - lucene - sonarqube - xmlhttprequest - listbox - initialization - switch-statement - internationalization - boolean - components - apache-camel - google-play - gdb - ios5 - serial-port - return - ldap - youtube-api - pivot - eclipse-plugin - latex - frameworks - tags - c++17 - containers - subquery - github-actions - embedded - dataset - foreign-keys - asp-classic - label - uinavigationcontroller - delegates - copy - google-cloud-storage - struts2 - migration - protractor - base64 - uibutton - queue - find - sql-server-2008-r2 - arguments - composer-php - append - jaxb - stack - zip - tailwind-css - cucumber - autolayout - ide - entity-framework-6 - iteration - popup - r-markdown - windows-7 - vb6 - clang - g++ - airflow - hover - ssl-certificate - jqgrid - range - gmail Next You’ll be prompted to create an account to view your personalized homepage. 1. 1. [Home](https://stackoverflow.com/) 2. [Questions](https://stackoverflow.com/questions) 3. [AI Assist](https://stackoverflow.com/ai-assist) 4. [Tags](https://stackoverflow.com/tags) 5. [Challenges](https://stackoverflow.com/beta/challenges) 6. [Chat](https://chat.stackoverflow.com/?tab=explore) 7. [Articles](https://stackoverflow.blog/contributed?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=so-blog&utm_content=experiment-articles) 8. [Users](https://stackoverflow.com/users) 9. [Companies](https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) 10. [Collectives]() 11. Communities for your favorite technologies. [Explore all Collectives](https://stackoverflow.com/collectives-all) 2. Stack Internal Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work. [Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) 3. [Stack Internal]() 4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) ##### Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. [Learn more about Collectives](https://stackoverflow.com/collectives) **Stack Internal** Knowledge at work Bring the best of human thought and AI automation together at your work. [Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover) [![](https://stackoverflow.com/Content/Img/survey-cta.svg?v=171e02557b0d) How are we doing? Take our short survey](https://stackoverflow.com/survey/site-satisfaction/redirect?source=sidebar "Take our short survey") # [Arrow operator (-\>) usage in C](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c) [Ask Question](https://stackoverflow.com/questions/ask) Asked 16 years ago Modified [1 year, 10 months ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c?lastactivity "2024-05-20 03:58:20Z") Viewed 687k times This question shows research effort; it is useful and clear 347 Save this question. Show activity on this post. I am reading a book called "Teach Yourself C in 21 Days" (I have already learned Java and C\# so I am moving at a much faster pace). I was reading the chapter on pointers and the `->` (arrow) *operator* came up without explanation. I think that it is used to call members and functions (like the equivalent of the `.` (dot) operator, but for pointers instead of members). But I am not entirely sure. Could I please get an explanation and a code sample? - [c](https://stackoverflow.com/questions/tagged/c "show questions tagged 'c'") - [pointers](https://stackoverflow.com/questions/tagged/pointers "show questions tagged 'pointers'") - [syntax](https://stackoverflow.com/questions/tagged/syntax "show questions tagged 'syntax'") [Share](https://stackoverflow.com/q/2575048 "Short permalink to this question") Share a link to this question Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this question](https://stackoverflow.com/posts/2575048/edit) Follow Follow this question to receive notifications [edited Sep 23, 2019 at 12:29](https://stackoverflow.com/posts/2575048/revisions "show all edits to this post") [![Jonathan Hall's user avatar](https://i.sstatic.net/3mW5P.png?s=64)](https://stackoverflow.com/users/13860/jonathan-hall) [Jonathan Hall](https://stackoverflow.com/users/13860/jonathan-hall) 80\.7k1919 gold badges163163 silver badges207207 bronze badges asked Apr 4, 2010 at 16:21 [![Mohit Deshpande's user avatar](https://www.gravatar.com/avatar/ba84fa0f6814411b1a060d07ea2f1950?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/200477/mohit-deshpande) [Mohit Deshpande](https://stackoverflow.com/users/200477/mohit-deshpande) 55\.6k7777 gold badges199199 silver badges257257 bronze badges 10 - 135 Get a better book. [norvig.com/21-days.html](http://norvig.com/21-days.html) joshperry – [joshperry](https://stackoverflow.com/users/30587/joshperry "42,547 reputation") 2010-04-04 16:35:13 +00:00 [Commented Apr 4, 2010 at 16:35](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment8614156_2575048) - 12 qrdl is correct -- the "Learn X in Y days" books are generally garbage. In addition to K\&R, I would also recommend Prata's "C Primer Plus", which goes into more depth than K\&R. J. Taylor – [J. Taylor](https://stackoverflow.com/users/176410/j-taylor "4,945 reputation") 2011-04-29 23:29:00 +00:00 [Commented Apr 29, 2011 at 23:29](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment6704061_2575048) - 3 @Steve That question deals with C++. Calling it a caused some confusion for me when I started reading about operator overloading in that other answer, which is not relevant in C. Johann – [Johann](https://stackoverflow.com/users/825588/johann "4,422 reputation") 2013-05-13 19:42:28 +00:00 [Commented May 13, 2013 at 19:42](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment23737535_2575048) - 1 @Belton The hard way series are bad, the guy says stuff that wasn't even relevant when he wrote the book and he doesn't care about good practices. Bálint – [Bálint](https://stackoverflow.com/users/4934560/b%C3%A1lint "4,054 reputation") 2017-06-25 19:51:06 +00:00 [Commented Jun 25, 2017 at 19:51](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment76480944_2575048) - 2 @uh\_big\_mike\_boi Nonsense. Comments like these are helpfully pointing out that this is a poor book, and have provided several superior alternatives. It doesn't matter in the least whether the OP did or did not say, or thinks or does not think, it is a great book. It isn't, and that needs to be stated. Comments like *yours* are not helpful. user207421 – [user207421](https://stackoverflow.com/users/207421/user207421 "312,066 reputation") 2024-05-20 04:17:30 +00:00 [Commented May 20, 2024 at 4:17](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment138400172_2575048) \| [Show **5** more comments](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c "Expand to show all comments on this post") ## 11 Answers 11 Sorted by: [Reset to default](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c?answertab=scoredesc#tab-top) This answer is useful 622 Save this answer. Show activity on this post. `foo->bar` is equivalent to `(*foo).bar`, i.e. it gets the member called `bar` from the struct that `foo` points to. [Share](https://stackoverflow.com/a/2575050 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/ "The current license for this post: CC BY-SA 2.5") [Improve this answer](https://stackoverflow.com/posts/2575050/edit) Follow Follow this answer to receive notifications answered Apr 4, 2010 at 16:23 [![sepp2k's user avatar](https://www.gravatar.com/avatar/7a561ec0875fcbbe3066ea8fe288ec77?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/149392/sepp2k) [sepp2k](https://stackoverflow.com/users/149392/sepp2k) 372k5656 gold badges687687 silver badges687687 bronze badges Sign up to request clarification or add additional context in comments. ## 8 Comments Add a comment [![](https://www.gravatar.com/avatar/5cfe5f7d64f44be04f147295f5c7b88e?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/207421/user207421) user207421 [user207421](https://stackoverflow.com/users/207421/user207421) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment44662605_2575050) It's worth noting that if the dereference operator had been made postfix, as in Pascal, the `->` operator would not have been needed at all, as it would have been equivalent to the much more legible `foo*.bar`. The whole mess of typedef-ing functions with all the extra parentheses would have been avoided as well. 2015-01-26T06:04:03.507Z+00:00 71 Reply - Copy link [![](https://lh6.googleusercontent.com/-_a7aQ1gNiFY/AAAAAAAAAAI/AAAAAAAAABw/2usMjLqKwgI/s48-rj/photo.jpg)](https://stackoverflow.com/users/4441547/aaron-franke) Aaron Franke [Aaron Franke](https://stackoverflow.com/users/4441547/aaron-franke) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment95043791_2575050) So would `foo*.bar` and `(*foo).bar` both be equivalent to `foo->bar`? What about `Foo myFoo = *foo; myFoo.bar`? 2019-01-09T08:21:15.583Z+00:00 1 Reply - Copy link [![](https://www.gravatar.com/avatar/efa67d5890612632e062ede96a7c3be7?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/1950345/reichhart) reichhart [reichhart](https://stackoverflow.com/users/1950345/reichhart) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment97128545_2575050) No, he is just saying *IF* the creators of C would have made the dereference operator as POSTfix operator instead of PREfix then it would have been more easy. But it IS a prefix operator in C. 2019-03-16T09:59:44.197Z+00:00 19 Reply - Copy link [![](https://www.gravatar.com/avatar/d1dec1aa6accf3589489ebd42634f7a0?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/2742717/swift-friday-pie) Swift - Friday Pie [Swift - Friday Pie](https://stackoverflow.com/users/2742717/swift-friday-pie) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment103325570_2575050) @user207421 nah, it would cause more parents.. so far, there is priority of () and \[\] to the right above \* to the left. if they all on one side, you'll have put more parents. Same in expressions, because of conflict with multiplication operator. Pascal ^ could be an option but it was reserved for bit operation, still more parents. 2019-10-22T06:32:32.49Z+00:00 1 Reply - Copy link [![](https://www.gravatar.com/avatar/7a561ec0875fcbbe3066ea8fe288ec77?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/149392/sepp2k) sepp2k [sepp2k](https://stackoverflow.com/users/149392/sepp2k) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment117424951_2575050) @b0fh There's no technical reason why the language designers couldn't have made dereferencing implicit in this case (Rust does it in this case and other cases as well), but they didn't. Possibly because they felt that all dereferences should be explicit in the code and/or because they wanted to keep the language rules as simple as possible. Note that C++ smart pointers have their own methods (like `use_count()` for shared\_ptrs), so there it is necessary to distinguish between calling a method on the pointer vs. the pointee, but of course that didn't retroactively affect the design of C. 2021-03-01T11:39:12.26Z+00:00 4 Reply - Copy link Add a comment \| Show 3 more comments This answer is useful 163 Save this answer. Show activity on this post. Yes, that's it. It's just the dot version when you want to access elements of a struct/class that is a pointer instead of a reference. ``` Copy ``` That's it\! [Share](https://stackoverflow.com/a/2575051 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/2575051/edit) Follow Follow this answer to receive notifications [edited Jun 22, 2021 at 19:28](https://stackoverflow.com/posts/2575051/revisions "show all edits to this post") [![Hymns For Disco's user avatar](https://www.gravatar.com/avatar/7d6ff70b084489c4f456062ce83ab40f?s=64&d=identicon&r=PG&f=y&so-version=2)](https://stackoverflow.com/users/11424673/hymns-for-disco) [Hymns For Disco](https://stackoverflow.com/users/11424673/hymns-for-disco) 8,55522 gold badges2626 silver badges4242 bronze badges answered Apr 4, 2010 at 16:23 [![Jack's user avatar](https://www.gravatar.com/avatar/d7d8f2d9904d869783dcff1803c6fbcb?s=64&d=identicon&r=PG&f=y&so-version=2)](https://stackoverflow.com/users/121747/jack) [Jack](https://stackoverflow.com/users/121747/jack) 134k3333 gold badges252252 silver badges349349 bronze badges ## 5 Comments Add a comment [![](https://www.gravatar.com/avatar/98a347823cd1db90af884b227a29c29e?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/582917/cmcdragonkai) CMCDragonkai [CMCDragonkai](https://stackoverflow.com/users/582917/cmcdragonkai) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment53434074_2575051) Since pvar is uninitialised, how would you initialise it if you wanted pvar to point to a new struct, that is not `pvar = &var`? 2015-09-26T14:27:43.737Z+00:00 3 Reply - Copy link user2442944 user2442944 [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment69658592_2575051) The question was specifically about C, which does not have classes or reference variables. 2016-12-19T19:34:24.81Z+00:00 1 Reply - Copy link [![](https://www.gravatar.com/avatar/63c7436d6b05ba912a5cb0b0bf254c93?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/236062/zibri) Zibri [Zibri](https://stackoverflow.com/users/236062/zibri) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment85804535_2575051) hmm shouldn't you do a malloc before writing to pvar struct foo\* pvar; ?? pvar-\>y write to unallocated space\! 2018-03-21T08:46:14.66Z+00:00 1 Reply - Copy link [![](https://www.gravatar.com/avatar/efa67d5890612632e062ede96a7c3be7?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/1950345/reichhart) reichhart [reichhart](https://stackoverflow.com/users/1950345/reichhart) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment97128601_2575051) pvar initialization: Initialize all members manually to some defaults you want to have or use something like calloc() if zero fill would be fine for you. 2019-03-16T10:03:23.05Z+00:00 0 Reply - Copy link [![](https://graph.facebook.com/817637355019559/picture?type=large)](https://stackoverflow.com/users/8429828/yuri-aps) Yuri Aps [Yuri Aps](https://stackoverflow.com/users/8429828/yuri-aps) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment100578086_2575051) shouldn't it be: pvar = malloc(sizeof(struct foo)) or malloc(sizeof(\*pvar))?? 2019-07-14T02:01:46.4Z+00:00 5 Reply - Copy link Add a comment This answer is useful 50 Save this answer. Show activity on this post. I'd just add to the answers the "why?". `.` is standard member access operator that has a higher precedence than `*` pointer operator. When you are trying to access a struct's internals and you wrote it as `*foo.bar` then the compiler would think to want a 'bar' element of 'foo' (which is an address in memory) and obviously that mere address does not have any members. Thus you need to ask the compiler to first dereference whith `(*foo)` and then access the member element: `(*foo).bar`, which is a bit clumsy to write so the good folks have come up with a shorthand version: `foo->bar` which is sort of member access by pointer operator. [Share](https://stackoverflow.com/a/46843382 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0") [Improve this answer](https://stackoverflow.com/posts/46843382/edit) Follow Follow this answer to receive notifications answered Oct 20, 2017 at 6:20 [![Lukasz Matysiak's user avatar](https://www.gravatar.com/avatar/8206b13e39a75abbb283fd09dd8f0613?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/8187710/lukasz-matysiak) [Lukasz Matysiak](https://stackoverflow.com/users/8187710/lukasz-matysiak) 93177 silver badges1111 bronze badges ## Comments Add a comment This answer is useful 41 Save this answer. Show activity on this post. `a->b` is just short for `(*a).b` in every way (same for functions: `a->b()` is short for `(*a).b()`). [Share](https://stackoverflow.com/a/2575052 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/ "The current license for this post: CC BY-SA 2.5") [Improve this answer](https://stackoverflow.com/posts/2575052/edit) Follow Follow this answer to receive notifications answered Apr 4, 2010 at 16:23 [![Peter Alexander's user avatar](https://www.gravatar.com/avatar/4a2e0b7d905b4a7841e489e9f100eb50?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/235825/peter-alexander) [Peter Alexander](https://stackoverflow.com/users/235825/peter-alexander) 54\.5k1414 gold badges123123 silver badges169169 bronze badges ## 2 Comments Add a comment [![](https://i.sstatic.net/3N48C.png?s=64)](https://stackoverflow.com/users/7571052/asheketchum) AsheKetchum [AsheKetchum](https://stackoverflow.com/users/7571052/asheketchum) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment76889794_2575052) is there documentation that says it also works that way for methods? 2017-07-06T19:15:24.173Z+00:00 1 Reply - Copy link [![](https://www.gravatar.com/avatar/5cfe5f7d64f44be04f147295f5c7b88e?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/207421/user207421) user207421 [user207421](https://stackoverflow.com/users/207421/user207421) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment138400185_2575052) @AsheKetchum It has to work that way for methods, because of the respective definitions. It doesn't need to be explicitly stated, although it may well be. 2024-05-20T04:19:27.143Z+00:00 0 Reply - Copy link This answer is useful 25 Save this answer. Show activity on this post. `foo->bar` is only shorthand for `(*foo).bar`. That's all there is to it. [Share](https://stackoverflow.com/a/2575053 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/ "The current license for this post: CC BY-SA 2.5") [Improve this answer](https://stackoverflow.com/posts/2575053/edit) Follow Follow this answer to receive notifications answered Apr 4, 2010 at 16:23 [![Matti Virkkunen's user avatar](https://www.gravatar.com/avatar/b03410a67ad6b9cf3fce7b0bf45084c8?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/227267/matti-virkkunen) [Matti Virkkunen](https://stackoverflow.com/users/227267/matti-virkkunen) 65\.5k99 gold badges140140 silver badges162162 bronze badges ## Comments Add a comment This answer is useful 18 Save this answer. Show activity on this post. Well I have to add something as well. Structure is a bit different than array because array is a pointer and structure is not. So be careful\! Lets say I write this useless piece of code: ``` Copy ``` Here pointer `ptr` points to the address (**\!**) of the structure variable `audi` but beside address structure also has a **chunk of data** (**\!**)! The first member of the **chunk of data** has the same address than structure itself and you can get it's data by only dereferencing a pointer like this `*ptr` *(no braces)*. But If you want to acess any other member than the first one, you have to add a designator like `.km`, `.kph`, `.kg` which are nothing more than offsets to the base address of the **chunk of data**... But because of the [preceedence](https://en.cppreference.com/w/cpp/language/operator_precedence) you can't write `*ptr.kg` as access operator `.` is evaluated before dereference operator `*` and you would get `*(ptr.kg)` which is not possible as pointer has no members! And compiler knows this and will therefore issue an error e.g.: ``` Copy ``` Instead you use this `(*ptr).kg` and you force compiler to **1st** dereference the pointer and enable acess to the **chunk of data** and **2nd** you add an offset (designator) to choose the member. Check this image I made: [![enter image description here](https://i.sstatic.net/hSaCj.png)](https://i.sstatic.net/hSaCj.png) But if you would have nested members this syntax would become unreadable and therefore `->` was introduced. I think readability is the only justifiable reason for using it as this `ptr->kg` is much easier to write than `(*ptr).kg`. Now let us write this differently so that you see the connection more clearly. `(*ptr).kg` ⟹ `(*&audi).kg` ⟹ `audi.kg`. Here I first used the fact that `ptr` is an *"address of `audi`"* i.e. `&audi` and fact that *"reference"* `&` and *"dereference"* `*` operators cancel eachother out. [Share](https://stackoverflow.com/a/61566897 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/61566897/edit) Follow Follow this answer to receive notifications [edited May 8, 2020 at 10:05](https://stackoverflow.com/posts/61566897/revisions "show all edits to this post") answered May 2, 2020 at 22:02 [![71GA's user avatar](https://i.sstatic.net/Jz42l.jpg?s=64)](https://stackoverflow.com/users/689242/71ga) [71GA](https://stackoverflow.com/users/689242/71ga) 1,54199 gold badges4747 silver badges8585 bronze badges ## Comments Add a comment This answer is useful 12 Save this answer. Show activity on this post. ``` Copy ``` Here to access the values of `i` and `j` we can use the variable `a` and the pointer `p` as follows: `a.i`, `(*p).i` and `p->i` are all the same. Here `.` is a "Direct Selector" and `->` is an "Indirect Selector". [Share](https://stackoverflow.com/a/42173683 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/42173683/edit) Follow Follow this answer to receive notifications [edited Apr 21, 2023 at 11:54](https://stackoverflow.com/posts/42173683/revisions "show all edits to this post") answered Feb 11, 2017 at 8:01 [![JgWangdu's user avatar](https://www.gravatar.com/avatar/7018c8ff4a937c398ab19bbd1c851275?s=64&d=identicon&r=PG&f=y&so-version=2)](https://stackoverflow.com/users/7173263/jgwangdu) [JgWangdu](https://stackoverflow.com/users/7173263/jgwangdu) 31722 silver badges99 bronze badges ## Comments Add a comment This answer is useful 1 Save this answer. Show activity on this post. I had to make a small change to Jack's program to get it to run. After declaring the struct pointer pvar, point it to the address of var. I found this solution on page 242 of Stephen Kochan's Programming in C. ``` Copy ``` Run this in vim with the following command: ``` Copy:!gcc -o var var.c && ./var ``` Will output: ``` Copy ``` [Share](https://stackoverflow.com/a/28934009 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0") [Improve this answer](https://stackoverflow.com/posts/28934009/edit) Follow Follow this answer to receive notifications answered Mar 9, 2015 at 1:35 [![Rich Vogt's user avatar](https://www.gravatar.com/avatar/0632cac8e7c2122efdd45f93657737ec?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/2069474/rich-vogt) [Rich Vogt](https://stackoverflow.com/users/2069474/rich-vogt) 9311 silver badge99 bronze badges ## 1 Comment Add a comment [![](https://www.gravatar.com/avatar/cbe5582212032c88ca6592defb48f36b?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/187890/jibberia) jibberia [jibberia](https://stackoverflow.com/users/187890/jibberia) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment53969484_28934009) vim tip: use `%` to represent the current filename. Like so: `!gcc % && ./a.out` 2015-10-12T08:10:06.733Z+00:00 4 Reply - Copy link This answer is useful 1 Save this answer. Show activity on this post. The `->` operator makes the code more readable than the `*` operator in some situations. Such as: (quoted from the [EDK II project](http://sourceforge.net/projects/edk2/)) ``` Copy ``` The `_EFI_BLOCK_IO_PROTOCOL` struct contains 4 function pointer members. Suppose you have a variable `struct _EFI_BLOCK_IO_PROTOCOL * pStruct`, and you want to use the good old `*` operator to call it's member function pointer. You will end up with code like this: `(*pStruct).ReadBlocks(...arguments...)` But with the `->` operator, you can write like this: `pStruct->ReadBlocks(...arguments...)`. Which looks better? [Share](https://stackoverflow.com/a/31943584 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0") [Improve this answer](https://stackoverflow.com/posts/31943584/edit) Follow Follow this answer to receive notifications [edited Feb 11, 2017 at 9:32](https://stackoverflow.com/posts/31943584/revisions "show all edits to this post") [![Donald Duck is with Ukraine's user avatar](https://www.gravatar.com/avatar/2e017633cda5465e6683c74992cdec5e?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/4284627/donald-duck-is-with-ukraine) [Donald Duck is with Ukraine](https://stackoverflow.com/users/4284627/donald-duck-is-with-ukraine) 9,1002323 gold badges8282 silver badges109109 bronze badges answered Aug 11, 2015 at 13:47 [![smwikipedia's user avatar](https://www.gravatar.com/avatar/8ccbe08a132ba61eae9ff8984ca44e81?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/264052/smwikipedia) [smwikipedia](https://stackoverflow.com/users/264052/smwikipedia) 65\.2k101101 gold badges336336 silver badges519519 bronze badges ## Comments Add a comment This answer is useful 1 Save this answer. Show activity on this post. ``` Copy ``` output is 5 5 5 [Share](https://stackoverflow.com/a/50638678 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/50638678/edit) Follow Follow this answer to receive notifications answered Jun 1, 2018 at 7:56 [![prashanth's user avatar](https://www.gravatar.com/avatar/41bbf47f6beda0353b8bab81d78afdc3?s=64&d=identicon&r=PG&f=y&so-version=2)](https://stackoverflow.com/users/9847765/prashanth) [prashanth](https://stackoverflow.com/users/9847765/prashanth) 1111 bronze badge ## Comments Add a comment This answer is useful 0 Save this answer. Show activity on this post. ``` Copy ``` [Share](https://stackoverflow.com/a/30545537 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0") [Improve this answer](https://stackoverflow.com/posts/30545537/edit) Follow Follow this answer to receive notifications [edited May 30, 2015 at 11:29](https://stackoverflow.com/posts/30545537/revisions "show all edits to this post") [![Tommy Andersen's user avatar](https://i.sstatic.net/fjZrH.jpg?s=64)](https://stackoverflow.com/users/111143/tommy-andersen) [Tommy Andersen](https://stackoverflow.com/users/111143/tommy-andersen) 7,31011 gold badge3535 silver badges5555 bronze badges answered May 30, 2015 at 11:23 [![Gopal Rao's user avatar](https://www.gravatar.com/avatar/abfdb1c6d07813cb5db72d98c3b55d86?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/4956051/gopal-rao) [Gopal Rao](https://stackoverflow.com/users/4956051/gopal-rao) 911 bronze badge ## 2 Comments Add a comment [![](https://www.gravatar.com/avatar/5cfe5f7d64f44be04f147295f5c7b88e?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/207421/user207421) user207421 [user207421](https://stackoverflow.com/users/207421/user207421) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment138400189_30545537) Mere code is not an answer. You have to explain. 2024-05-20T04:20:25.757Z+00:00 0 Reply - Copy link [![](https://i.sstatic.net/TMTape2J.png?s=64)](https://stackoverflow.com/users/17726418/cppuix) CPPUIX [CPPUIX](https://stackoverflow.com/users/17726418/cppuix) [Over a year ago](https://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c#comment138415086_30545537) ["Not an answer" flagging guidelines](https://meta.stackoverflow.com/a/265553/17726418). 2024-05-21T17:24:13.567Z+00:00 0 Reply - Copy link **[Protected question](https://stackoverflow.com/help/privileges/protect-questions)**. To answer this question, you need to have at least 10 reputation on this site (not counting the [association bonus](https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus-and-how-does-it-work)). The reputation requirement helps protect this question from spam and non-answer activity. Start asking to get answers Find the answer to your question by asking. [Ask question](https://stackoverflow.com/questions/ask) Explore related questions - [c](https://stackoverflow.com/questions/tagged/c "show questions tagged 'c'") - [pointers](https://stackoverflow.com/questions/tagged/pointers "show questions tagged 'pointers'") - [syntax](https://stackoverflow.com/questions/tagged/syntax "show questions tagged 'syntax'") See similar questions with these tags. - The Overflow Blog - [He designed C++ to solve your code problems](https://stackoverflow.blog/2026/04/07/he-designed-c-to-solve-your-code-problems/?cb=1) - [Seizing the means of messenger production](https://stackoverflow.blog/2026/04/03/seizing-the-means-of-messenger-production/?cb=1) - Featured on Meta - [Retiring the beta site](https://meta.stackoverflow.com/questions/438628/retiring-the-beta-site?cb=1) - [Policy: Generative AI (e.g., ChatGPT) is banned](https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1) Community activity Last 1 hr - Users online activity 3585 users online - 7 questions - 9 answers - 12 comments - 66 upvotes Popular tags [c++](https://stackoverflow.com/questions/tagged/c++)[javascript](https://stackoverflow.com/questions/tagged/javascript)[c](https://stackoverflow.com/questions/tagged/c)[php](https://stackoverflow.com/questions/tagged/php)[python](https://stackoverflow.com/questions/tagged/python)[c\#](https://stackoverflow.com/questions/tagged/c) Popular unanswered question [EF Load Multiple Entity References in one call to Load()](https://stackoverflow.com/questions/38020931) [entity-framework](https://stackoverflow.com/questions/tagged/entity-framework)[entity-framework-6](https://stackoverflow.com/questions/tagged/entity-framework-6) [![User avatar](https://www.gravatar.com/avatar/9de90c2e28d4cbbc53461d805f537927?s=256&d=identicon&r=PG)](https://stackoverflow.com/users/2245759) [user2245759](https://stackoverflow.com/users/2245759) - 487 3,574 days ago #### Linked [10](https://stackoverflow.com/questions/14087274/difference-between-and-in-c?lq=1 "Question score (upvotes - downvotes)") [Difference between "-\>" and "." in C](https://stackoverflow.com/questions/14087274/difference-between-and-in-c?noredirect=1&lq=1) [0](https://stackoverflow.com/questions/6585797/what-is-this-operator-in-c?lq=1 "Question score (upvotes - downvotes)") [What is this operator(-\>) in C?](https://stackoverflow.com/questions/6585797/what-is-this-operator-in-c?noredirect=1&lq=1) [1](https://stackoverflow.com/questions/12572999/what-is-the-operator-doing-in-copywithzone?lq=1 "Question score (upvotes - downvotes)") [What is the -\> operator doing in -copyWithZone:?](https://stackoverflow.com/questions/12572999/what-is-the-operator-doing-in-copywithzone?noredirect=1&lq=1) [2](https://stackoverflow.com/questions/6552835/help-understanding-operator-in-c?lq=1 "Question score (upvotes - downvotes)") [Help understanding -\> operator in C](https://stackoverflow.com/questions/6552835/help-understanding-operator-in-c?noredirect=1&lq=1) [0](https://stackoverflow.com/questions/23450929/linked-lists-when-to-use-and-when?lq=1 "Question score (upvotes - downvotes)") [Linked lists when to use -\> and when .?](https://stackoverflow.com/questions/23450929/linked-lists-when-to-use-and-when?noredirect=1&lq=1) [\-4](https://stackoverflow.com/questions/34257544/structure-syntax-in-c?lq=1 "Question score (upvotes - downvotes)") [Structure Syntax in C (-\>)](https://stackoverflow.com/questions/34257544/structure-syntax-in-c?noredirect=1&lq=1) [\-3](https://stackoverflow.com/questions/43584186/if-i-have-a-pointer-pointing-at-a-struct-how-can-i-access-one-of-its-members?lq=1 "Question score (upvotes - downvotes)") [If I have a pointer pointing at a struct, how can I access one of its members?](https://stackoverflow.com/questions/43584186/if-i-have-a-pointer-pointing-at-a-struct-how-can-i-access-one-of-its-members?noredirect=1&lq=1) [\-2](https://stackoverflow.com/questions/71054409/what-is-operator-called-and-purpose-does-it-serve?lq=1 "Question score (upvotes - downvotes)") [What is "-\>" operator called and purpose does it serve?](https://stackoverflow.com/questions/71054409/what-is-operator-called-and-purpose-does-it-serve?noredirect=1&lq=1) [\-3](https://stackoverflow.com/questions/48041323/c-to-c-conversion-issues?lq=1 "Question score (upvotes - downvotes)") [C++ to C Conversion issues](https://stackoverflow.com/questions/48041323/c-to-c-conversion-issues?noredirect=1&lq=1) [\-1](https://stackoverflow.com/questions/54450243/i-dont-understand-when-to-use-the-arrow-and-when-to-use-the-point?lq=1 "Question score (upvotes - downvotes)") [I don't understand when to use the arrow and when to use the point](https://stackoverflow.com/questions/54450243/i-dont-understand-when-to-use-the-arrow-and-when-to-use-the-point?noredirect=1&lq=1) [See more linked questions](https://stackoverflow.com/questions/linked/2575048?lq=1) #### Related [3](https://stackoverflow.com/questions/1706502/arrow-operator-with-arrays?rq=3 "Question score (upvotes - downvotes)") [\-\> Arrow operator with Arrays?](https://stackoverflow.com/questions/1706502/arrow-operator-with-arrays?rq=3) [1](https://stackoverflow.com/questions/6346224/what-does-this-mean-in-c-objective-c?rq=3 "Question score (upvotes - downvotes)") [What does this ' -\>' mean in c/objective-c?](https://stackoverflow.com/questions/6346224/what-does-this-mean-in-c-objective-c?rq=3) [4](https://stackoverflow.com/questions/8614727/c-pointer-syntax?rq=3 "Question score (upvotes - downvotes)") [C pointer syntax](https://stackoverflow.com/questions/8614727/c-pointer-syntax?rq=3) [4](https://stackoverflow.com/questions/9245844/what-does-the-operator-mean-in-c?rq=3 "Question score (upvotes - downvotes)") [What does the "-\>" operator mean in C++?](https://stackoverflow.com/questions/9245844/what-does-the-operator-mean-in-c?rq=3) [0](https://stackoverflow.com/questions/10374900/what-does-this-pointer-syntax-in-c-mean?rq=3 "Question score (upvotes - downvotes)") [what does this pointer syntax in C mean?](https://stackoverflow.com/questions/10374900/what-does-this-pointer-syntax-in-c-mean?rq=3) [338](https://stackoverflow.com/questions/13366083/why-does-the-arrow-operator-in-c-exist?rq=3 "Question score (upvotes - downvotes)") [Why does the arrow (-\>) operator in C exist?](https://stackoverflow.com/questions/13366083/why-does-the-arrow-operator-in-c-exist?rq=3) [0](https://stackoverflow.com/questions/17619694/pointer-references-mixing-and-syntax-confusion?rq=3 "Question score (upvotes - downvotes)") [Pointer references mixing '\*' and ' -\>' syntax confusion](https://stackoverflow.com/questions/17619694/pointer-references-mixing-and-syntax-confusion?rq=3) [\-1](https://stackoverflow.com/questions/18675176/explain-the-following-syntax-i-am-not-able-to-comprehend-this?rq=3 "Question score (upvotes - downvotes)") [Explain the following syntax, i am not able to comprehend this](https://stackoverflow.com/questions/18675176/explain-the-following-syntax-i-am-not-able-to-comprehend-this?rq=3) [2](https://stackoverflow.com/questions/19665247/operator-in-c-and-how-its-used?rq=3 "Question score (upvotes - downvotes)") ['-\>' operator in C and how it's used](https://stackoverflow.com/questions/19665247/operator-in-c-and-how-its-used?rq=3) [0](https://stackoverflow.com/questions/60745637/are-there-different-uses-of-the-arrow-mark-used-by-pointers-in-c-how-exa?rq=3 "Question score (upvotes - downvotes)") [Are there different uses of the arrow mark '-\>' used by pointers in C++? How exactly is it used?](https://stackoverflow.com/questions/60745637/are-there-different-uses-of-the-arrow-mark-used-by-pointers-in-c-how-exa?rq=3) #### [Hot Network Questions](https://stackexchange.com/questions?tab=hot) - [Why is space not a perfect vacuum?](https://physics.stackexchange.com/questions/870964/why-is-space-not-a-perfect-vacuum) - [How are uppercase Greek letters handled in T1?](https://tex.stackexchange.com/questions/761659/how-are-uppercase-greek-letters-handled-in-t1) - [Would these laws suitably regulate and minimise cannibalism?](https://worldbuilding.stackexchange.com/questions/273109/would-these-laws-suitably-regulate-and-minimise-cannibalism) - [How is the solar eclipse experienced by the Artemis II crew unique compared to what Apollo crews experienced?](https://space.stackexchange.com/questions/70419/how-is-the-solar-eclipse-experienced-by-the-artemis-ii-crew-unique-compared-to-w) - [What is \*state\* citizenship under the 14th Amendment, and how come you never hear much about it?](https://politics.stackexchange.com/questions/94495/what-is-state-citizenship-under-the-14th-amendment-and-how-come-you-never-hea) - [How to license different parts of an open source documentation project](https://opensource.stackexchange.com/questions/15732/how-to-license-different-parts-of-an-open-source-documentation-project) - [Which airport is this?](https://gaming.stackexchange.com/questions/418354/which-airport-is-this) - [When did the Discworld wizards stop being so cutthroat?](https://scifi.stackexchange.com/questions/303952/when-did-the-discworld-wizards-stop-being-so-cutthroat) - [Starting maths postdoc later than sooner](https://academia.stackexchange.com/questions/226426/starting-maths-postdoc-later-than-sooner) - [What makes an emitter resistor redundant in Zener-referenced emitter follower?](https://electronics.stackexchange.com/questions/767740/what-makes-an-emitter-resistor-redundant-in-zener-referenced-emitter-follower) - [Shree Krishna on obtaining Knowledge](https://hinduism.stackexchange.com/questions/69815/shree-krishna-on-obtaining-knowledge) - [What is the Solubility of Na2SO3 in Methanol](https://chemistry.stackexchange.com/questions/195337/what-is-the-solubility-of-na2so3-in-methanol) - [History of the usage of "IKEA clue" instead of "charade"](https://puzzling.stackexchange.com/questions/137591/history-of-the-usage-of-ikea-clue-instead-of-charade) - [Wave equation that reduces to the Hamilton-Jacobi-Einstein equation](https://physics.stackexchange.com/questions/870988/wave-equation-that-reduces-to-the-hamilton-jacobi-einstein-equation) - [Natural numbers as sums of powers of distinct numbers \#2](https://mathoverflow.net/questions/509953/natural-numbers-as-sums-of-powers-of-distinct-numbers-2) - [With respect to what input should an NP verification be polynomial?](https://math.stackexchange.com/questions/5131848/with-respect-to-what-input-should-an-np-verification-be-polynomial) - [How to plot y = x^{2/3} + 0.8 cos(kx) √(3-x²) in LaTeX TikZ](https://tex.stackexchange.com/questions/761671/how-to-plot-y-x2-3-0-8-coskx-%E2%88%9A3-x%C2%B2-in-latex-tikz) - [Turn a shark egg case into a tetrahedron](https://puzzling.stackexchange.com/questions/137596/turn-a-shark-egg-case-into-a-tetrahedron) - [Is there a way to guarantee that Lean 4 proofs cannot be adversarially tricked?](https://proofassistants.stackexchange.com/questions/6517/is-there-a-way-to-guarantee-that-lean-4-proofs-cannot-be-adversarially-tricked) - [Should I put a question mark after a box, table, or image?](https://english.stackexchange.com/questions/639424/should-i-put-a-question-mark-after-a-box-table-or-image) - [What pronouns do I use for a gendered position?](https://english.stackexchange.com/questions/639442/what-pronouns-do-i-use-for-a-gendered-position) - [How does 'everything is a file' not contradict 'do one thing and do it well'?](https://softwareengineering.stackexchange.com/questions/461068/how-does-everything-is-a-file-not-contradict-do-one-thing-and-do-it-well) - [Fibonacci - Memento pattern with recursion and some utilities](https://codereview.stackexchange.com/questions/301774/fibonacci-memento-pattern-with-recursion-and-some-utilities) - [How to remove the the infill of 2 combined parts?](https://blender.stackexchange.com/questions/346123/how-to-remove-the-the-infill-of-2-combined-parts) [Question feed](https://stackoverflow.com/feeds/question/2575048 "Feed of this question and its answers") # Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. ![](https://stackoverflow.com/posts/2575048/ivc/be0a?prg=c94de8bb-dd5f-4951-a1da-150309535b32) lang-c # Why are you flagging this comment? Probable spam. This comment promotes a product, service or website while [failing to disclose the author's affiliation](https://stackoverflow.com/help/promotion). Unfriendly or contains harassment/bigotry/abuse. This comment is unkind, insulting or attacks another person or group. Learn more in our [Abusive behavior policy](https://stackoverflow.com/conduct/abusive-behavior). Not needed. This comment is not relevant to the post. ``` ``` Enter at least 6 characters Something else. A problem not listed above. Try to be as specific as possible. ``` ``` Enter at least 6 characters Flag comment Cancel You have 0 flags left today # ![Illustration of upvote icon after it is clicked](https://stackoverflow.com/Content/Img/modal/img-upvote.png?v=fce73bd9724d) # Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation) Instead, you can save this post to reference later. Save this post for later Not now ##### [Stack Overflow](https://stackoverflow.com/) - [Questions](https://stackoverflow.com/questions) - [Help](https://stackoverflow.com/help) - [Chat](https://chat.stackoverflow.com/?tab=explore) ##### [Business](https://stackoverflow.co/) - [Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) - [Stack Data Licensing](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=data-licensing) - [Stack Ads](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) ##### [Company](https://stackoverflow.co/) - [About](https://stackoverflow.co/) - [Press](https://stackoverflow.co/company/press/) - [Work Here](https://stackoverflow.co/company/work-here/) - [Legal](https://stackoverflow.com/legal) - [Privacy Policy](https://stackoverflow.com/legal/privacy-policy) - [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public) - [Contact Us](https://stackoverflow.com/contact) - Cookie Settings - [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy) ##### [Stack Exchange Network](https://stackexchange.com/) - [Technology](https://stackexchange.com/sites#technology) - [Culture & recreation](https://stackexchange.com/sites#culturerecreation) - [Life & arts](https://stackexchange.com/sites#lifearts) - [Science](https://stackexchange.com/sites#science) - [Professional](https://stackexchange.com/sites#professional) - [Business](https://stackexchange.com/sites#business) - [API](https://api.stackexchange.com/) - [Data](https://data.stackexchange.com/) - [Blog](https://stackoverflow.blog/?blb=1) - [Facebook](https://www.facebook.com/officialstackoverflow/) - [Twitter](https://twitter.com/stackoverflow) - [LinkedIn](https://linkedin.com/company/stack-overflow) - [Instagram](https://www.instagram.com/thestackoverflow) Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.4.7.41816
Readable Markdown
Well I have to add something as well. Structure is a bit different than array because array is a pointer and structure is not. So be careful\! Lets say I write this useless piece of code: ``` #include <stdio.h> typedef struct{ int km; int kph; int kg; } car; int main(void){ car audi = {12000, 230, 760}; car *ptr = &audi; } ``` Here pointer `ptr` points to the address (**\!**) of the structure variable `audi` but beside address structure also has a **chunk of data** (**\!**)! The first member of the **chunk of data** has the same address than structure itself and you can get it's data by only dereferencing a pointer like this `*ptr` *(no braces)*. But If you want to acess any other member than the first one, you have to add a designator like `.km`, `.kph`, `.kg` which are nothing more than offsets to the base address of the **chunk of data**... But because of the [preceedence](https://en.cppreference.com/w/cpp/language/operator_precedence) you can't write `*ptr.kg` as access operator `.` is evaluated before dereference operator `*` and you would get `*(ptr.kg)` which is not possible as pointer has no members! And compiler knows this and will therefore issue an error e.g.: ``` error: ‘ptr’ is a pointer; did you mean to use ‘->’? printf("%d\n", *ptr.km); ``` Instead you use this `(*ptr).kg` and you force compiler to **1st** dereference the pointer and enable acess to the **chunk of data** and **2nd** you add an offset (designator) to choose the member. Check this image I made: [![enter image description here](https://i.sstatic.net/hSaCj.png)](https://i.sstatic.net/hSaCj.png) But if you would have nested members this syntax would become unreadable and therefore `->` was introduced. I think readability is the only justifiable reason for using it as this `ptr->kg` is much easier to write than `(*ptr).kg`. Now let us write this differently so that you see the connection more clearly. `(*ptr).kg` ⟹ `(*&audi).kg` ⟹ `audi.kg`. Here I first used the fact that `ptr` is an *"address of `audi`"* i.e. `&audi` and fact that *"reference"* `&` and *"dereference"* `*` operators cancel eachother out.
Shard169 (laksa)
Root Hash714406497480128969
Unparsed URLcom,stackoverflow!/questions/2575048/arrow-operator-usage-in-c s443