The compiler would assume a default prototype of
int fnc(...)
So no type checking on the arguments and the return type is int.
(If a proper declaration is not found before call.)
ok. the compiler only assumes default type int when no declaration is found prior to calling and.is that what u mean?and what about the arguments listed in the call?
so what i understood till now is that any function's scope is from the point it is declared till the end of the file.i mean if i declare any function(say f1()) inside any other function(say f2()) then i can use f1() from the point of declaration to the end of the file whether i call it in some other function's definition.if i call f1() from any other fucntion defined before f2() then it'll be an error.
ok. the compiler only assumes default type int when no declaration is found prior to calling and.is that what u mean?
Yes.
and what about the arguments listed in the call?
Nothing. The compiler assumes that the prototype takes an infinite number of arguments, such as:
int myfunction();
Originally Posted by Adak
io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
Originally Posted by Salem
You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.
Outside of your DOS world, your header file is meaningless.
ok. the compiler only assumes default type int when no declaration is found prior to calling and.is that what u mean?and what about the arguments listed in the call?
they are compared 1-to-1 with the function parameters
Nothing. The compiler assumes that the prototype takes an infinite number of arguments, such as:
int myfunction();
hmm...that's why we should explicitly write int myfunc(void) to make the function not take any arguments.and is this(compiler's assunption) the reason for the compiler not showing any error while i used getch() without its proper header.
Yes, you need to do that in prototypes, otherwise the compiler assumes it takes an infinite number of arguments.
Originally Posted by Adak
io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
Originally Posted by Salem
You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.
Outside of your DOS world, your header file is meaningless.
hmm...that's why we should explicitly write int myfunc(void) to make the function not take any arguments.and is this(compiler's assunption) the reason for the compiler not showing any error while i used getch() without its proper header.
If you enable warnings, which is generally a good idea, it will warn you for not having a prototype.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.