typedef struct

This is a discussion on typedef struct within the C Programming forums, part of the General Programming Boards category; Code: typedef struct { int number; int count; }NUMBER; what does this mean?...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    11

    typedef struct

    Code:
    typedef struct 
    {	
    	int number;	
    	int count;
    }NUMBER;
    what does this mean?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Code:
    typedef this that;
    makes "that" an alias for "this", as a type. So you can use a shorter or more descriptive name instead of the formal name.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    11
    so in this case, it creates a new data type "NUMBER" as an alias for "int number" and "int count".

    so what about struct?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Well, no. "This" is
    Code:
    struct
    {
        int number;
        int count;
    }
    and "that" is
    Code:
    NUMBER
    hence NUMBER is now a synonym for the unnamed struct listed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help assignment due tomorrow
    By wildiv in forum C Programming
    Replies: 6
    Last Post: 01-27-2010, 07:38 PM
  2. Converting from C to C++
    By Taka in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2009, 02:16 AM
  3. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  4. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 07:18 AM
  5. typedef struct question
    By flevine100 in forum C Programming
    Replies: 1
    Last Post: 09-03-2002, 09:34 PM

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