davek@lakesys.UUCP (Dave Kraft) (02/22/89)
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@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
guy@auspex.UUCP (Guy Harris) (02/23/89)
>How come the following small program works under Turbo C 1.5 and not under >Unix? You mean "...under Turbo C 1.5 but not under the mumblemumblemumble compiler on UNIX"; there are many many different C compilers under UNIX. Not all of the latter support function prototyping; if you have one that doesn't, that's why your program only works when you don't use function prototyping....
gwyn@smoke.BRL.MIL (Doug Gwyn ) (02/23/89)
In article <414@lakesys.UUCP> davek@lakesys.UUCP (Dave Kraft) writes: >How come the following small program works under Turbo C 1.5 and not under >Unix? Probably because your implementation of UNIX C doesn't support protoypes.