Does anyone have problems with string input in Xcode 3.2?

For some reason excode is throwing this error when I try to insert a string into a string.

test (5640) malloc: * error for object 0x1000041c0: pointer was not freed * set breakpoint in malloc_error_break for debugging Program signal: "SIGABRT". sharedlibrary apply-load-rules all

Here's the code that produced the following:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string hello;

    cout << "Enter a string";
    cin >> hello;

    return 0;

}

      

Anyone have a solution?

+2


source to share


1 answer


According to this forum: http://discussions.apple.com/message.jspa?messageID=10236050#10236050

Technically, this is a warning, not an error. This is a bug in the C ++ GCC library. Remind me again why I no longer write C ++ code. You think that in 2009 they would have stupid things like this fixed.



You can avoid this by making sure your hello variable is initialized with something to start with.

Or you can turn off pedantic warnings. Select the debug target and double-click it or Command-i. Scroll down to "GCC 4.2 - Preprocessing". Select "Preprocessor Macros" and delete it. You will no longer receive a warning message. You are still freeing unallocated memory, but you can complain to GCC about it.

+1


source







All Articles