新手请问一个char数组的东西
新手请教一个char数组的东西。
define:
std::map <std::string, std::vector <FromTo *> > *Langure;
gchar* getSiteType();
main:
gchar* getSiteType(){
int _L = Langure-> size();
gchar *_type = new gchar[_L];
gchar *_type1;
int j = 0;
for(std::map <std::string, std::vector <FromTo *> > ::iterator i = Langure-> begin(); i != Langure-> end(); ++i){
//_type[j] = (i-> first.c_str());
strcpy(_type1 , (i-> first).c_str());
_type[j] = _type1;//从类型 ‘gchar*’ 到类型 ‘char’ 的转换无效
j++;
}
return _type;
}
我想把std::map里的first放到一个gchar的数组里, 这里总是不行。
谢谢朋友~
------解决方案--------------------
只能放到gchar数组的数组里。不过,按你现在的函数,你不可能告诉调用者数组里有多少个gchar数组。
define:
std::map <std::string, std::vector <FromTo *> > *Langure;
gchar* getSiteType();
main:
gchar* getSiteType(){
int _L = Langure-> size();
gchar *_type = new gchar[_L];
gchar *_type1;
int j = 0;
for(std::map <std::string, std::vector <FromTo *> > ::iterator i = Langure-> begin(); i != Langure-> end(); ++i){
//_type[j] = (i-> first.c_str());
strcpy(_type1 , (i-> first).c_str());
_type[j] = _type1;//从类型 ‘gchar*’ 到类型 ‘char’ 的转换无效
j++;
}
return _type;
}
我想把std::map里的first放到一个gchar的数组里, 这里总是不行。
谢谢朋友~
------解决方案--------------------
只能放到gchar数组的数组里。不过,按你现在的函数,你不可能告诉调用者数组里有多少个gchar数组。