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:
#include <iostream>
#include <string>
int main(void)
{
using std::cin;
using std::cout;
using std::string;
string name= "";
cout << "What is your name?\n";
cin>> name;
cout << "\nHello " << name.c_str() << "\n";
return 0;
}
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
Abort trap
logout
[Process completed]
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.
Whenever I attempt to use the following code:
#include <iostream>
#include <string>
int main(void)
{
using std::cin;
using std::cout;
using std::string;
string name= "";
cout << "What is your name?\n";
cin>> name;
cout << "\nHello " << name.c_str() << "\n";
return 0;
}
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
Abort trap
logout
[Process completed]
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.