标签:string
jstring ifaceStr, jstring opPackageNameStr
String16(opPackageName.c_str()),client, String8(iface.c_str())
2. String16 name16 = String16("HellOThEWrolD");
String8 name8 = String8(name16);
3. string8 -> char*
String8& initParam
initParam.string()
4. char* -> string16
char *buf = new char[strlen(C_name8)+1];
name16 = String16(buf);
5. string -> char*
string s1 = "abcdeg";
const char *k = s1.c_str();
const char *t = s1.data();
如果要转换成char*,可以用string的一个成员函数copy实现。
string s1 = "abcdefg";
char *data;
int len = s1.length();
data = (char *)malloc((len+1)*sizeof(char));
s1.copy(data,len,0);
string8 与 const char* 就是同一个, 如果要转换成非const, 就需要copy
本文出自 “FlyingBear” 博客,请务必保留此出处http://lindt.blog.51cto.com/9699125/1900333
标签:string
原文地址:http://lindt.blog.51cto.com/9699125/1900333