How is it that the structure pointer is declared with same name of the structure?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivek nandan
    New Member
    • Jan 2011
    • 9

    How is it that the structure pointer is declared with same name of the structure?

    The following code,
    Code:
    struct devinfo{
    int a;
    int b;
    };
    struct devinfo *devinfo;
    is perfectly legal in C. How is it that the structure pointer is declared with same name of the structure? Does it has a special meaning or significance? Any help will be appreciated.
    Last edited by Niheel; Jan 21 '11, 10:27 AM.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    structure names and variable names are stored in a different name space within the compiler so it is perfectly valid to use the structure name as the name of a variable (in this case a pointer to a structure of the type named).

    It has no special significance.

    Comment

    • vivek nandan
      New Member
      • Jan 2011
      • 9

      #3
      thanks banfa!

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        It has no special significance to the compiler; however it ought to have significance to you the programmer. Using the same name for unrelated things is a good way to get really confused.

        Comment

        Working...