Re: Hellp with type promotion
- From: "Robin Haigh" <ecl6rsh@xxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 15:33:20 -0000
<manochavishal@xxxxxxxxx> wrote in message
news:1141134465.963604.87530@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
it does promote to int type.
If we dont explicitly declare the function prototype, the function
argument character is promoted to int.
void test();
int main(void)
{
int n;
char c = 'C';
test(c);
printf("\nsize in main %d",sizeof(c));
return 0;
}
void test(c)
{
printf("size in func %d",sizeof(c));
}
This prints:
size in func 4
size in main 1
So if we dont tell compiler explicitly in the prototype the type of
arguments they are promoted.
But here's the odd thing. If you change the call
test(c);
to
test();
so that you don't pass an argument at all, you still get the same output
--
RSH
.
- Follow-Ups:
- Re: Hellp with type promotion
- From: A. Sinan Unur
- Re: Hellp with type promotion
- References:
- Hellp with type promotion
- From: manochavishal@xxxxxxxxx
- Re: Hellp with type promotion
- From: Ravi Uday
- Re: Hellp with type promotion
- From: manochavishal@xxxxxxxxx
- Hellp with type promotion
- Prev by Date: Re: need help getting the results of the system function into a variable
- Next by Date: Re: Printing Patterns using for loops
- Previous by thread: Re: Hellp with type promotion
- Next by thread: Re: Hellp with type promotion
- Index(es):
Relevant Pages
|