Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Jan 2, 2001

Octal and Hexadecimal Output


By default, cout displays integral values as decimal numbers. You can override this setting and have integral values displayed in hexadecimal and octal notations by using the 'hex' and 'oct' manipulators. Use the 'dec' manipulator to restore the default setting:
 
int n=17;
cout<<hex<<n<<endl;  // output 11
cout<<oct<<n<<endl; // output 21
cout<<dec<<n<<endl; // output 17
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap