Thread: Problem referencing structure elements by pointer

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    If the typedef is visible, that's fine -- you just need to call it "configurationOptions" (since that's the name you gave it in the typedef) instead of "struct configurationsOptions".

    Edit to add: At this point, I would say, if you have most of your code referring to "struct configurationOptions" to not typedef it but make it a named struct; if it's just a few mentions, go ahead and change those mentions. There's no advantage either way (typedef vs. named struct), so do whatever causes the least amount of typing at this point.

  2. #17
    Join Date
    Oct 2007
    Inside my computer
    Anonymous means it simply doesn't have a name - nothing more.
    Again, remove the "struct" keyword because there is no struct named configurationsOptions. There is only something named configurationsOptions.
    As long as you have a full declaration of the struct, you can do a sizeof on it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Registered User
    Join Date
    May 2008
    Many thanks - all clear now and code working

  4. #19
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    I wouldn't recommend typedef'ing it the same as the struct name,

    I tend to do, along with a lot of other people
    typedef struct name_s
    } name_t;
    That way you know, name_t is a type, and name_s is a struct.
    Last edited by zacs7; 06-13-2008 at 07:29 PM.

  5. #20
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Note that there's nothing actually wrong with using the same name for the structure as you do for the typedef, it's just rather confusing.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  3. accessing structure pointer problem
    By godhand in forum C Programming
    Replies: 2
    Last Post: 04-09-2004, 10:52 PM
  4. Pointer to structure problem
    By unregistered in forum C Programming
    Replies: 3
    Last Post: 12-24-2001, 07:54 AM
  5. C structure within structure problem, need help
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-30-2001, 05:48 PM