I wrote the following code, a simple string test and I get an error message every time I run it saying "Hey(5031) malloc: *** error for object 0x1000041c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap"
How do I fix this?
*** set a breakpoint in malloc_error_break to debug
Abort trap"
How do I fix this?
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string user_first_name;
string user_last_name;
cout << "First name: ";
cin >> user_first_name;
cout << "Last name: ";
cin >> user_last_name
string user_full_name = user_first_name + " " + user_last_name;
cout << "Your name is " << user_full_name << "\n";
}
Last edited by a moderator: