After testing the user input and confirming contains only numbers, how do I convert the string to an integer. Have spent hours attempting to do so, obvoisly without success....

Or change the code below to accept an integer and test...?
#include <iostream>
#include <cstring>
#include <string>
#include <cctype>

using namespace std;

int main()
{
string answer;
char again;
do
{
cout << "Enter a number or letter ";
cin >> answer;
for (int i = 0; i < answer.length(); i++)
{
if (!isdigit(answer[i]))
{
cout << answer << " is not a number!" << endl;
break;
}
}
cout << "\nAnswer is " << answer << endl;
cout << "more> ";
cin >> again;
}while(again == 'y');
return 0;
}