C syntax: unsigned myvar;

This is a discussion on C syntax: unsigned myvar; within the C Programming forums, part of the General Programming Boards category; Hi there, just a quick question, what happens to variables of this kind in C compiler, defaults to system int? ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    15

    Red face C syntax: unsigned myvar;

    Hi there,
    just a quick question, what happens to variables of this kind in C compiler, defaults to system int?

    I am just adapting the zlib compression example zpipe.c:
    Code:
    int ret, flush;
    unsigned have;
    z_stream strm;
    ...
       have = CHUNK - strm.avail_out;
       if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
    also just a guide on etiquette in posting on this forum, is there a syntax section for quickie questions like this?


    thanks

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    unsigned have;
    If your referring to an unsigned int, it is basically an int which can only hold positive values.
    The default in C is the signed int which allows you to hold both negative and positive values.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    15
    Quote Originally Posted by Spidey View Post
    If your referring to an unsigned int
    You may have overlooked my question. I am referring to "unsigned" alone...What is it's intended meaning. if "unsigned" converts to "unsigned int" then which C syntax does this conform to?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by lordmule View Post
    You may have overlooked my question. I am referring to "unsigned" alone...What is it's intended meaning. if "unsigned" converts to "unsigned int" then which C syntax does this conform to?
    The part of the C syntax that says that "unsigned" and "unsigned int" refer to the same type (in the same way that "int" and "signed int" refer to the same type).

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    15
    excellent. thanks for that.

  6. #6
    C++11 User Tux0r's Avatar
    Join Date
    Nov 2008
    Location
    Sweden
    Posts
    135
    Quote Originally Posted by lordmule View Post
    excellent. thanks for that.
    Note however that this does not stop you from saying unsigned char for example.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  4. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

Tags for this Thread


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