非常に基本的な概念上の疑問。このばかげた質問で私を憎まないでください
メイン関数のスレッドから以下のような関数を呼び出すと
char * function()
{
char message[10];
.................
....do sth ......
return message;
}
この場合、内部バッファーは自動であり、スレッド関数が戻るとすぐに消えます。
しかし、これを行うとそれは機能します
char * function()
{
char * message = (char*)malloc(10);
.................
....do sth ......
return message;
}
以下の行と混同しています。これはどのように問題を解決しますか?
Each thread will allocate a different array and store the address of that array in a stack variable. Every thread has its own stack so automatic data objects are different for each thread.