Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 7, 2012, 08:53 PM   #1
Marioqwe
macrumors newbie
 
Join Date: Apr 2012
Using C++ on Xcode getting HEX values

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.
Marioqwe is offline   0 Reply With Quote
Old Apr 7, 2012, 08:58 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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
lee1210 is offline   0 Reply With Quote
Old Apr 7, 2012, 09:11 PM   #3
Marioqwe
Thread Starter
macrumors newbie
 
Join Date: Apr 2012
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
Marioqwe is offline   0 Reply With Quote
Old Apr 7, 2012, 09:17 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Marioqwe View Post
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
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.
chown33 is offline   0 Reply With Quote
Old Apr 7, 2012, 09:36 PM   #5
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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
lee1210 is offline   0 Reply With Quote
Old Apr 7, 2012, 09:41 PM   #6
Marioqwe
Thread Starter
macrumors newbie
 
Join Date: Apr 2012
I see my mistake. How silly. Thank You.
Marioqwe is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
nMP hex vs. MP 5,1 hex akadmon Mac Pro 8 Jan 7, 2014 03:43 AM
Quad vs Hex TheKnifeFight Mac Pro 10 Dec 23, 2013 10:47 PM
Dealing with Hex blubyu iPhone/iPad Programming 22 Jun 9, 2013 12:15 PM
Moving from xcode 3.2 to xcode 4.5.2 compilation error for 'abs' macro in stdlib.h hrishidev Mac Programming 7 Jun 2, 2013 10:36 AM

Forum Jump

All times are GMT -5. The time now is 03:28 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC