Jun 5, 2009 at 2:20am UTC
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 ???
Jun 5, 2009 at 6:27pm UTC
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.
Jun 5, 2009 at 7:07pm UTC
>.> That's a pretty funny combination.
Jun 5, 2009 at 11:43pm UTC
Bazzy, that worked !!!!!!!
Thanks so much.
Jun 6, 2009 at 12:47am UTC
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!