#include<iostream>
#include<string>
using namespace std;
int main() {
string str = "hello world!";
const char *p = str.c_str();
cout << p << endl;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main() {
string str="hello world!";
char *p;
int len = str.length();
p=(char *)malloc((len+1)*sizeof(char));
str.copy(p,len,0);
cout << p << endl;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main() {
char *p = "hello world!";
string str(p);
cout << str << endl;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main() {
const char *p = "hello world!";
string str(p);
cout << str << endl;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main() {
const char *p = "hello world!";
char *s = (char *)p;
cout << s << endl;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main() {
char *p = "hello world!";
const char *s = (const char*)p;
cout << s << endl;
return 0;
}