Re: float
Glynn Clements <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
phoenixxz wrote:
> float i=1.34;
> printf("%f",i);
>
>
> ->> 0
> why?
You need to include <stdio.h> and write a main() function ;)
Beyond that: stdout will be line-buffered (if it's associated with a
terminal, block-buffered otherwise), so you should add a "\n" to the
end of the format string.
The lack of line buffering might have an effect if the program
terminates abnormally (exit() or returning from main() should cause
buffered streams to be flushed).
A working example:
$ cat test.c
#include <stdio.h>
int main(void)
{
float i=1.34;
printf("%f\n",i);
return 0;
}
$ gcc test.c
$ ./a.out
1.340000
--
Glynn Clements <[email protected]>