Thread: variables

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    variables

    I am learning C and I have an issue about the defining of variables which I think is more because of my book than my lack of understanding. In one of the program listings the book defins a variable called "money". From the rest of the program it is clearly an unsigned int but in the definition it just says:

    unsigned money;
    i but it compiles ok. Am I to assume that it assumes the variable is an int unless stated i.e. that unsigned money; is equivalent to unsigned int money;
    thanks if you can shed some light on this
    Matt

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    When typing unsigned the compiler understands that you mean an unsigned int. The same with long, which is translated to long int. This is most likely to save time and space, though I prefer to print the whole declaration.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    wanshu

    ok, thanks for that clarification. I guessed it was something like that but I was not completely certain.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  3. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  4. Replies: 6
    Last Post: 01-02-2004, 01:01 PM
  5. functions to return 2 variables?
    By tim in forum C Programming
    Replies: 5
    Last Post: 02-18-2002, 02:39 PM