Re: Hellp with type promotion




<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



.



Relevant Pages