Re: Printf question.
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 08:43:44 -0500
Charles Richmond wrote:
usenet@xxxxxxx wrote:
praeiji <spacecaps@xxxxxxxxx> wrote:
But why are they typecasted to int? Does it come from gcc when it sees "%d" and the printf function?
No, they are not typecasted, but `promoted', which is not the same thing. Promotion is what happens when you call a function that has no prototype, or when a function with a variable number (variadic) of arguments like printf() is called. With promotion, all arguments are converted to a generic 'bigger' type: char and short to int, float to double.
Type promotion can also happen when you do mixed mode arithmetic.
Or even unmixed-mode arithmetic:
short x = 1, y = 2; short z = x + y; /* see the "int"? */
-- Eric Sosman esosman@xxxxxxxxxxxxxxxxxxx .
- References:
- Printf question.
- From: praeiji
- Re: Printf question.
- From: usenet
- Re: Printf question.
- From: praeiji
- Re: Printf question.
- From: usenet
- Re: Printf question.
- From: Charles Richmond
- Printf question.
- Prev by Date: Re: How to stop reading a file?
- Next by Date: Re: Structure size and binary format
- Previous by thread: Re: Printf question.
- Next by thread: Re: Printf question.
- Index(es):
Relevant Pages
|