Home » programming

iostream中输入输出十六进制数

By: Zhiqiang Ma On: Nov 12, 2008 Views: 6 No Comment Print Email
Tags: ,

很简单, 直接上示例代码:

#include <fstream>
#include <iomanip>

using std::cout;
using std::ifstream;
using std::ios;
using std::hex;

int main(){
    ifstream is("e:\test\test.txt");
    int i = 0;
    is >> hex >> i;
    cout << hex << i << endl;
    is.close();
    return 0;
}

Read more:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.