I have a C++ Program:
#include <iostream>
using namespace std;
int main (){
char x [10] = "abc";
system (sprintf ("mkdir ", "%s", x)); //error happens here, can't
//convert int to const char*
return 0;
}
results in:
sys.c:8:37: error: invalid conversion from ‘int’ to ‘const char*’
Where am I converting an int to a char?
system expects a const char * as input, whereas sprintf returns an int. This is the problem which is leading your error. Also, the first argument of sprintf must be a writable buffer of sufficient size.