(六)QT专题-字符串引用传递
2023-02-12 本文已影响0人
GoodTekken
Page421
字符参数传递:
//Method 1
static char str[10] = {'H','e','l','l','o','W','o','r','l','d'};
return (void*)(&(str));
//Method 2
static string str = "HelloWorld2";
static char ch[4096]; //依然需要字符指针
strcpy(ch,str.c_str()); //将字符串转换为字节数组,然后再进行传递
return (void*)(&(ch));
参数接收
char* str;
if(pid[1] != 0)
{
pthread_join(pid[1],(void**)&str);
cout<<"&str:"<<(&str)<<endl;
printf("Hahaha\n");
printf("get thread 1 exitcode: %s\n",str);
}