Mail Archives: djgpp/2005/01/08/05:17:29
> From: "Samuel Lauber" <sam124 AT operamail DOT com>
> Date: Sat, 08 Jan 2005 06:54:37 GMT
>
> int printf(char *, ...);
> int main(void)
> {
> printf("%f\n", 1);
> }
>
> Compile it, and it would say `Unnormal'. Is this a bug?
A bug, yes, but in your program, not in the compiler or the library.
If you compile with the -Wall switch, which prints warnings for
dubious code, the compiler says:
cfp.c: In function `main':
cfp.c:4: warning: double format, different type arg (arg 2)
cfp.c:5: warning: control reaches end of non-void function
The first warning is directly related to what you see: you should use
printf("%f\n", 1.0);
i.e. make the argument be a float or a double, not an int.
The second warning says that you should end this program with
return 0;
since `main' is declared a function that returns an int.
- Raw text -