Below is the small program
Displays OutPut as = -0.028148Code:#include<stdio.h> #include<stdlib.h> int main() { printf(" %#f\n", 415); return 0; }
Unable to understand, please help.....
I am using NetBeans 6 under Ubuntu.
Below is the small program
Displays OutPut as = -0.028148Code:#include<stdio.h> #include<stdlib.h> int main() { printf(" %#f\n", 415); return 0; }
Unable to understand, please help.....
I am using NetBeans 6 under Ubuntu.
with each run, it displays a random number
Where you supply 415 - that's supposed to be a reference to a float variable.
Mainframe assembler programmer by trade. C coder when I can.
You're telling it to print a double, but you're not passing it a double.
Use 415.0 instead.
Welcome to the complete lack of type safety in printf!
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
you put 4 bytes on stack, but using format f - which reads 8 bytes and interprets them as double... So you get 4 random bytes of garbage in your output.
Make your number to be consistent with the format, for example 415.0
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
thanks guys,