Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Oct 2011 23:58:03 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: need to check for hex in C: how/
Message-ID:  <20111016235803.40b2181a.freebsd@edvax.de>
In-Reply-To: <20111016212628.GA30284@thought.org>
References:  <20111016212628.GA30284@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16 Oct 2011 14:26:31 -0700, Gary Kline wrote:
> 
> if n == 15 and x is the int. i can say 
> 
> if ((int)x == 15)  Or to check if x == 'A' i can cast x to (char)x.
> 
> what's the syntax to chec if x is , say, 32/

The integer types are automatically casted, no matter if
you compare (int) or (char) to a numerical or character
value.

int i;
char c;

if(i == 32 || i == ' ') ...
if(c == 32 || c == ' ') ...

Functions or macros that deal with characters usually
do return (int), even though one would expect (char).




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111016235803.40b2181a.freebsd>