Difference between '->' and '.'

This is a discussion on Difference between '->' and '.' within the C Programming forums, part of the General Programming Boards category; I was wondering, when making programs with structures, what is the difference when calling the structure's members using the '.' ...

  1. #1
    UCF Mystic_Skies's Avatar
    Join Date
    Oct 2004
    Posts
    33

    Difference between '->' and '.'

    I was wondering, when making programs with structures, what is the difference when calling the structure's members using the '.' operator and the '->' operator? It seems like they would be the same thing. I've tried looking this up on the FAQ's but can't seem to find an answer.

    Also, if they are the same then is one standard and one is not?

    My code runs fine when I use '->' and I get this error when I use the '.':

    error: request for member 'format' in something not a structure or union

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Basically . is used to get a member of a struct or union. -> is used to dereference a pointer to a struct or union and get a member from it. -> is the same as (*obj).member

  3. #3
    UCF Mystic_Skies's Avatar
    Join Date
    Oct 2004
    Posts
    33
    Thanks Thantos, helpful as always.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. small -> big -> bigger -> bigger than bigger -> ?
    By happyclown in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-11-2009, 01:12 PM
  2. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 11:26 AM
  3. Dev-C++ -> Tools - > Editor -> Syntax
    By Yuri2 in forum C++ Programming
    Replies: 19
    Last Post: 07-03-2006, 08:48 AM
  4. > > > Urgent Help < < <
    By CodeCypher in forum C Programming
    Replies: 2
    Last Post: 01-31-2006, 02:06 PM
  5. Difference Tab -> Algebra
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-10-2002, 05:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21