Cin not getting hex value.

Cin not getting hex value.

uint32_t operandA;
uint32_t operandB;

cout <<"Enter data ra: " ;
cin >> hex >> operandA;
cout << "ra=0x" << hex << operandA << endl;

cout <<"Enter data rb: " ;
cin >> hex >> operandB;
cout << "rb=0x" << hex << operandB << endl;

My output is:
Enter data ra: 12345678
ra=0x12345678
Enter data rb: ffffffff
rb=0x0 <---------------------why is this happening ???


It works for me.
Hi

Is there some include file i'm not using?

Here is what i am using:
#include <stdint.h>
#include <iostream>
#include <stdio.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include <assert.h>
#include <libelf.h>
#include <algorithm>
#include <cstring>
#include<cctype>
#include "crcdemo.h"
using namespace std;

I am using Linux, and using g++ compiler.
closed account (S6k9GNh0)
>.> That's a pretty funny combination.
#include <iomanip> ?
Bazzy, that worked !!!!!!!

Thanks so much.
Strange, I am seeing the problem again after recompiling :(

It seems to break out of the cin's as soon as i enter a hex no such as a1b1c1d1.
It seems ok with 12345678.

Please help!
Topic archived. No new replies allowed.