In the following code
#include <stdlib.h> //atoi
#include <string>
using namespace std;
namespace roman
{
string convert( int input )
{
string inputStr = to_string(input);
if(inputStr.size()==4)
{
return string( atoi( inputStr[0] ), 'M')+convert(stoi(inputStr.substr(1, npos)));//error here
}
}
}
I am getting the titular error in the return
line. I think it has something to to with the atoi function. It takes a const char*
as the input value. I need to know how to turn the first character in inputStr
into a const char*
. I tried appending .c_str()
to the end of inputStr[0]
, but that gave me the error request for member c_str which is of non-class type char
. Anyone have some ideas?