Re: questions of unsigned int, function prototypes

From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 09/15/04


Date: Wed, 15 Sep 2004 09:56:53 +0100

In article <sAQ1d.368572$OB3.173995@bgtnsc05-news.ops.worldnet.att.net>,
away <Gusalpine@spambs.com> writes
>For a unsigned int used as a counter, it keeps increasing its value. Will
>overflow happen at end? How to handle it if it happens?

Unlike signed types, the C (and C++) Standard fully specifies what
happens to overflow for unsigned integers. The value wraps back through
zero. I.e. the unsigned values represent a modular arithmetic (with a
division operator that ignores the modularity)

>
>What're purposes about using function prototypes in C?

To allow the compiler to check that the arguments in calls have
appropriate types to match the parameters in the declaration.

-- 
Francis Glassborow      ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


Relevant Pages