|
-
August 10th, 2005, 03:48 AM
#1
Format Specifier!
Hi All,
Is there is any format specifier, which can be used to print the sign of the number?
For example,
If I enter 10, it should print as +10.
If I enter -2, it should print as -2.
With Thanks and Regards,
A.Ilamparithi
-
August 10th, 2005, 03:59 AM
#2
Re: Format Specifier!
With printf, there is one.
Try this one:
Code:
printf("the integer is : %+i",10);
-
August 10th, 2005, 04:02 AM
#3
Re: Format Specifier!
With iostream:
Code:
std::cout << std::showpos << 42 << std::noshowpos;
There is a flag showpos in the format flags of ios, set by the manipulator std::showpos, and removed by the manipulator std::noshowpos.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|