Solved

Simple but confused question

Posted on 2004-04-16
2
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

717 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