Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Simple but confused question

Posted on 2004-04-16
2
Medium Priority
?
165 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 100 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 100 total points
ID: 10842580
try putting
cout.unsetf(ios::dec);
before all.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

604 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