Re: Hellp with type promotion
- From: "Default User" <defaultuserbr@xxxxxxxxx>
- Date: 28 Feb 2006 18:24:49 GMT
manochavishal@xxxxxxxxx wrote:
int main(void)
{
char c = 'C';
test(c);
return 0;
}
void test(char c)
{
printf("Size of char is %d",sizeof(c));
}
1. This code is not legal. You don't have a declaration for test, and
the definition is different than the default declaration you would get
with a pre-C99 compiler. Also, printf() is a variadic function a
requires a prototype. The best way is to include <stdio.h>
2. Even if there were a legal implicit declaration or an old-style
declaration, that wouldn't matter. Except for variable-length arrays,
sizeof is performed at compile time. What the arguments get promoted to
at run-time have no bearing on what's printed there. It will be
sizeof(char), which is guaranteed to be 1, always.
Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
.
- References:
- Hellp with type promotion
- From: manochavishal@xxxxxxxxx
- Hellp with type promotion
- Prev by Date: Re: Random Number Generators....
- Next by Date: Re: Random Number Generators....
- Previous by thread: Re: Hellp with type promotion
- Next by thread: Re: Hellp with type promotion
- Index(es):
Relevant Pages
|