Prototyping help needed
Dave Kraft
davek at lakesys.UUCP
Wed Feb 22 07:39:47 AEST 1989
Hi,
I have a question:
How come the following small program works under Turbo C 1.5 and not under
Unix?
main()
{
int a = 0, b = 0, c;
int add(int, int);
printf("\nEnter 2 ints: ");
scanf("%d%d", &a, &b);
c = add(a, b);
printf("\nc = %d\n\n", c);
}
int add(int a, int b)
{
return(a + b);
}
Now, when I code it as follows:
main()
{
int a = 0, b = 0, c;
int add(int, int);
printf("\nEnter 2 ints: ");
scanf("%d%d", &a, &b);
c = add(a, b);
printf("\nc = %d\n\n", c);
}
int add(a, b)
int a, b;
{
return(a + b);
}
It works as it should. Why??
--
davek at lakesys.lakesys.com -or-
uunet!marque!lakesys!davek
"The meek will inherit the earth, the rest of us will go to the stars"
-- 'Omni' (magazine) button
More information about the Comp.lang.c
mailing list