You should do
int error=regexec(®ex,cppstring.c_str(),nmatch,pmatch,eflags);
The second argument of regexec() and the return value of std::string::c_str() are both (const char *), so that’s probably not the cause of your issue.
You should post the compiler error message and the part of the code that you suspect to be causing the problem.