Thread: typedef struct

  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,336
    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,336
    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, 08: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, 08:18 AM
  5. typedef struct question
    By flevine100 in forum C Programming
    Replies: 1
    Last Post: 09-03-2002, 09:34 PM