I want to pass an argument to a function, which takes a const char **
#include<iostream>
using namespace std;
void testFunc(const char **test){}
string testString = "This is a test string";
int main()
{
const char *tempC = testString.c_str();
testFunc(&tempC);
return 0;
}
This code works fine, But I dont want to go through the temporary variable tempC. I want to pass testString.c_str() directly. Like the following,
int main()
{
testFunc(&testString.c_str());
return 0;
}
But, it shows error,
error C2102: '&' requires l-value
Is it possible to do it without using the temp variable.