|Oct 23, 2010, 10:26 PM||#1|
Problem with using strings in Xcode (C++)
First off, I am brand new to Xcode. I have been trying to learn how to program in C++ for a couple of days now.
Whenever I attempt to use the following code:
string name= "";
cout << "What is your name?\n";
cout << "\nHello " << name.c_str() << "\n";
I always get the following error message:
What is your name?(1345) malloc: *** error for object 0x100004220: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
I have looked around the internet and I have found nothing that has helped me. I found one article that told me how to set the break point, but that didn't work. If anybody knows about this please answer. All answers are appreciated.
|Oct 23, 2010, 11:57 PM||#2|
Are you sure you set up the project correctly?
I just tried it in SL on the command line and a command line cpp project and they worked.
How did you create your project?(and what version of XCode are you using?)
|Oct 24, 2010, 12:10 AM||#3|
This comes up all the time. Maybe something at the top of the forum is in order. It comes down to killing Preprocessor macros in the debug build settings.
Also, string knows what to do with <<, so no need to c_str. [CODE][/CODE] tags are fun for everyone.
Edit: Now there's something in the forum header. Change away if it's not clear.
Last edited by lee1210; Oct 24, 2010 at 12:45 AM.
|Oct 24, 2010, 12:26 AM||#4|
You didn't ask, but you may want to give up on learning C++ with Xcode.
Why? If you're going to use C++ on Windows, you should learn it on Windows. If you're going to program for the Mac, you'll want to use Objective-C (in general).
iMac 21.5", 3.06GHz, 4 GB, 2 TB HD.
iPod Touch 3G.
|Oct 24, 2010, 10:32 AM||#5|
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|XCode 5 DP and Java Problem||aquethys||Mac Programming||0||Aug 28, 2013 10:59 PM|
|Xcode OpenGL Ram Problem||jmfel1926||Mac Programming||5||Aug 21, 2013 07:06 PM|
|Problem with XCode 4 .6||Senor Cuete||Mac Programming||7||Feb 11, 2013 10:15 AM|
|After updating XCode, output terminal problem||iMacFarlane||Mac Programming||9||Oct 4, 2012 12:29 AM|
|Xcode problem||JamesP.||Mac Applications and Mac App Store||0||Jul 4, 2012 11:41 AM|
All times are GMT -5. The time now is 02:16 PM.