Does anybody know what's wrong with this code?
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
string a;
getline(cin, a);
for(;;)
{
string x;
x=1;
string b;
getline(cin, b);
string c;
getline(cin, c);
string d;
d=a+b;
string e;
e=b+c;
if(b=="1")
{
return 0;
}
rename(d, e);
}
}
It says that the error is on the
rename(d,e);
part. And it gives an error
cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'const char*' for argument '1' to 'int rename(const char*, const char*)
So I'm assuming it can't convert string to char. Does anybody know how to do it and send the corrected part?
rename(d.c_str(), e.c_str());renamedoes. All that can be seen in your post is the signature ofrename. what @Sebastian Hoffmann says suits the signature, but does it produce the desired effect?stdio.h)std::rename, and askers don't need to post details of standard functions. You could look up documentation if unfamiliar with the function