fegge said:
well,see this:its result on my compiler.
of the two values 12 and 25 ,the mimimum is 2.
oh,why?
Assuming that you observed the two rules of comp.lang.c about code
1. Compiled the code and (if possible) ran it
and
2. Posted the precise code (via cut-and-paste) that you used in "1" above
Then...
because your compiler is using what you meant as a forward reference /
prototype / whatever:
int min(int ,int );
as the actual function, since the later line:
int mim(int a,int b)
doesn't satisfy the forward reference.
It's doing nothing when it's called, and you're getting what ever happens to be
where ever your compiler stores the return value from an integer function. On
many machines that's the primary accumulator of the CPU.
Didn't you get a linker warning? I get:
x.obj(x.c) : error L2029: '_min' : unresolved external
when I try to link this.
What are you using for a compiler/linker? I haven't used anything that would
let me get away with this sort of thing in 25 or 30 years. And even then, I
seem to recall that it choked on the "int, int" part.
When I change "int mim(int a,int b)" to "int min(int a,int b)" I get no
linker errors, and the run-time result is:
input two intergers: 12 25
of the two values 12 and 25 ,the mimimum is 12.
By the way, interesting that you also spelled "minimum" in the output message
starting with "mim".
- Bill