Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Marioqwe

macrumors newbie
Original poster
Apr 7, 2012
3
0
Hello,

Earlier today I tried to compile a simple program but I started getting HEX values for a number of things. For example, when I try to get a blank space, I get the following " 0x7fff7e71af78" with the space in front. When I try to get the number 16, I get "160x7fff7e71af78."

I'd really appreciate if somebody lets me know how to fix it.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
You'll need to be more specific than "for a lot of things". Is this appearing in output generated with cout? Can you show some compliance sample code? Generally you get hex values when you ask for them or when you inadvertently display a pointer.

-Lee
 

Marioqwe

macrumors newbie
Original poster
Apr 7, 2012
3
0
Thanks for replying.
I have tried these two things,

Code:
int main(int argc, char *argv[]) {
std::cout<<16<<std::endl;
return 0;
}

Code:
160x7fff7e71af78

Code:
int main(int argc, char *argv[]) {
std::cout<<"HOLA   "<<std::cout;
return 0;
}

Code:
HOLA   0x7fff7e71af78
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
Code:
int main(int argc, char *argv[]) {
std::cout<<16<<[COLOR="Red"]std::endl[/COLOR];
return 0;
}

Code:
160x7fff7e71af78

Code:
int main(int argc, char *argv[]) {
std::cout<<"HOLA   "<<[COLOR="red"]std::cout[/COLOR];
return 0;
}

Code:
HOLA   0x7fff7e71af78
I've hilited some important differences in red.

Personally, I don't believe the first output was actually produced by the first posted code. The address printed for the first output is identical to that printed for the second output. Instead, I suspect the posted first output was produced by something more like the second posted code.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Just to pile on, being that the addresses are the same in both examples it seems that this is a pointer to the same object, so you likely had std::cout as the last operand to << in both cases. You may have miscopied the code, failed to recompile at some point in your tests, etc. the moral here is that passing the object std::cout to its own << operator appears to print its address.

Basically, what changed is you started using the wrong operand. std::endl should be fine.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.