Solved

Simple but confused question

Posted on 2004-04-16
2
160 Views
Last Modified: 2010-04-01
RUn this program...

#include <iostream>
#include <iostream>
using namespace std;
main()
{
   cout.setf(ios::hex);
   cout.setf(ios::showbase);
   cout << 100 ;              
   return 0;
}

Why not displaying 0X64 ? (Which is the expected value)
0
Comment
Question by:prain
2 Comments
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 25 total points
ID: 10842569
For  dec, oct and hex you need to set the second parameter of setf to basefield:
   cout.setf(ios::hex, ios::basefield);
0
 
LVL 16

Assisted Solution

by:nonubik
nonubik earned 25 total points
ID: 10842580
try putting
cout.unsetf(ios::dec);
before all.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
ADO Memory leak with DELPHI 2007 37 181
what is the purpose of protos  and PARAMS in the readline library 3 67
SetCurrentDirectory path limit 7 122
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question