Ralph Krausse <[EMAIL PROTECTED]> wrote:
> Wow.... Didn't have my header included that define the function prototype.
> OK, so this leaves another question. How did the compiler comile without
> understanding the function (does it just assume? ) and if it does, what does
> it assume? btw, I am using CW.
A C compiler interprets a function having no prototype as
int foo()
Notice, the empty parens mean "unspecified arguments" in C, as opposed
to "no arguments" in C++. If you call foo with arguments, the compiler
just pushes them onto the stack in whatever type they happen to be.
Assuming you have
#define true 1
somewhere, calling
foo(true)
causes the compiler to push an int onto the stack. If, instead, you had
#define true 1.0
the compiler would have pushed a double onto the stack. In either case,
your foo function is looking for a one-byte argument, so it
misinterprets what your caller passes to it.
This, plus much more, is very well explained in "The C Programming
Language" by Kernighan and Ritchie. You should pick up a copy and read
it front to back, working through all the examples and excercises as
you go.
Disclaimer: I don't use CW, and I don't know how well the compiler
complies with the ANSI C standard.
--
Roger Chaplin
<[EMAIL PROTECTED]>