Re: Hellp with type promotion



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.

Great!!

Cheers
Vishal.

.



Relevant Pages

  • Re: [RFC/PATCH] unregister_node() for hotplug use
    ... this kind of stuff to the driver core maintainer, ... > Not needed for a function prototype. ... +void unregister_node ... +static int __init register_node_type ...
    (Linux-Kernel)
  • Re: algorithm for file shredding
    ... int mainnot int main ... variable only a void dummy return type, ... So don't use it even if your compiler illegally ... in C you may declare a function prototype to take no arguments as ...
    (comp.programming)
  • Re: Passing an array to a function
    ... void f(int a ) ... Only the first form can be used in a function prototype, ... (And the first doesn't *require* compile-time checking.) ...
    (comp.lang.c)
  • Re: Hellp with type promotion
    ... If we dont explicitly declare the function prototype, ... argument character is promoted to int. ... void test; ... Has nothing to do with promotion. ...
    (comp.lang.c)
  • Re: Hellp with type promotion
    ... If we dont explicitly declare the function prototype, ... argument character is promoted to int. ... void test; ...
    (comp.lang.c)