1. Use getline is very nice.
Code:
#include <iostream>
#include <string>
int main(void)
{
std::string myString;
std::getline(cin,myString); //saying get input from cin and save it in string
return 0;
}
2. You are not allocating memory for b your setting it to a so your delete is not really doing anything. What you are doing is not what delete is meant for, it is meant for things like this
Code:
#include <iostream>
int main()
{
int *ptr;
ptr = new int; //allocating memory for ptr
*ptr = 10; //setting the value of ptr to 10
std::cout<<*ptr<<std::endl;
delete ptr;
return 0;
}