今晚遇到点小问题,卡在基础知识,汗。。。
参考:https://segmentfault.com/q/1010000005936992
#include <iostream>
#include <string.h>
using namespace std;
/*
*解决需求:string[]转 char **
*/
int main() {
string array[] = { "1yuanpengfei", "2yuwangying", "3huangtilong", "4hongzhaoyang", "5gengchaogang", "6zhangshuai", "7shenshuai" };
int size = sizeof(array) / sizeof(string);
char **instrumentID = new char *[size];
for (int i = 0; i < size; i++) {
const char *charResult = array[i].c_str();
instrumentID[i] = new char[strlen(charResult) + 1];
strcpy(instrumentID[i], charResult);
cout << instrumentID[i] << endl;
}
}
文章的脚注信息由WordPress的wp-posturl插件自动生成
微信扫一扫,打赏作者吧~![[整理][转载]win下网卡抓包发包库Npcap使用](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2023/08/demo_1-1024x711.jpg&w=280&h=210&zc=1)
![[转载]基础数据char,int,double,string是线程安全的吗?](http://www.jyguagua.com/wp-content/themes/begin/img/random/11.jpg)
![[整理]how to run flask with pyqt5](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/03/pyqt_flask.png&w=280&h=210&zc=1)
![[已解决]LINK : fatal error LNK1158: cannot run 'rc.exe' 错误的解决办法](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/02/Snipaste_2021-02-17_15-18-26-1024x505.png&w=280&h=210&zc=1)