|Oct 23, 2010, 09: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, 10: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 23, 2010, 11:10 PM||#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 23, 2010 at 11:45 PM.
|Oct 23, 2010, 11:26 PM||#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, 09: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 09:59 PM|
|Xcode OpenGL Ram Problem||jmfel1926||Mac Programming||5||Aug 21, 2013 06:06 PM|
|Problem with XCode 4 .6||Senor Cuete||Mac Programming||7||Feb 11, 2013 09:15 AM|
|After updating XCode, output terminal problem||iMacFarlane||Mac Programming||9||Oct 3, 2012 11:29 PM|
|Xcode problem||JamesP.||Mac Applications and Mac App Store||0||Jul 4, 2012 10:41 AM|
All times are GMT -5. The time now is 01:26 PM.