W
wongjoekmeu
Hello All,
I have a following piece of code in C that I need to rewrite to C++.
However I just don't seem to be able to understand the format rules in
C.
The C code look like this:
I have two doubles x and y which has a value. Now their values are
written to
output with printf in the following way.
printf("%1f %3.2e\n",x,y);
I have read in a book that for instance %5.4f means write the float
with 5 digit
widt where 4 digit are dedicated to the decimal portion. However why
can I then
print out values with more then one digit ????
Can anyone explain this to me ????
And then what does %3.2e means then ??
That I will get at most 3 digits ???
where 2 are dedicated to the decimal ???
How can I rewrite this to C++ using cout to write to output ??
Thank you in advance
I have a following piece of code in C that I need to rewrite to C++.
However I just don't seem to be able to understand the format rules in
C.
The C code look like this:
I have two doubles x and y which has a value. Now their values are
written to
output with printf in the following way.
printf("%1f %3.2e\n",x,y);
I have read in a book that for instance %5.4f means write the float
with 5 digit
widt where 4 digit are dedicated to the decimal portion. However why
can I then
print out values with more then one digit ????
Can anyone explain this to me ????
And then what does %3.2e means then ??
That I will get at most 3 digits ???
where 2 are dedicated to the decimal ???
How can I rewrite this to C++ using cout to write to output ??
Thank you in advance