C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-19-2009, 06:41 PM   #1
Registered User
 
Join Date: Jun 2008
Posts: 8
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
lordmule is offline   Reply With Quote
Old 07-19-2009, 06:46 PM   #2
Webhead
 
Spidey's Avatar
 
Join Date: Jul 2009
Posts: 278
Quote:
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.
Spidey is offline   Reply With Quote
Old 07-19-2009, 08:27 PM   #3
Registered User
 
Join Date: Jun 2008
Posts: 8
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?
lordmule is offline   Reply With Quote
Old 07-19-2009, 08:35 PM   #4
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
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).
tabstop is offline   Reply With Quote
Old 07-22-2009, 02:28 PM   #5
Registered User
 
Join Date: Jun 2008
Posts: 8
excellent. thanks for that.
lordmule is offline   Reply With Quote
Old 07-23-2009, 12:15 AM   #6
C++0x User
 
Tux0r's Avatar
 
Join Date: Nov 2008
Location: Sweden
Posts: 133
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.
__________________
I like squirrels
Tux0r is offline   Reply With Quote
Reply

Tags
compiler, syntax, unsigned, zlib

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
more then 100errors in header hallo007 Windows Programming 20 05-13-2007 08:26 AM
We Got _DEBUG Errors Tonto Windows Programming 5 12-22-2006 05:45 PM
Converting a circulating mouse pointer to use a Potentionmeter phoenix23 C Programming 16 10-29-2006 05:04 AM
Using VC Toolkit 2003 Noobwaker Windows Programming 8 03-13-2006 07:33 AM
Dikumud maxorator C++ Programming 1 10-01-2005 06:39 AM


All times are GMT -6. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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