看板 Programming 關於我們 聯絡資訊
大家好 想要請問關於Pthreads的問題 使用環境:資管系工作站 ssh.im.ntu.edu.tw void *Fib_gen(void *param) // 這是thread function 的格式 { int num = atoi(param); int counter = 0; printf("Child Fibonacci Sequence: "); 但是 要用command line: int main(int argc, char * argv[]) 傳入參數 // create the thread pthread_create(&tid,&attr,Fib_gen,argv[1]); 結果得到這樣的error message Fib_Pthreads_4.cpp: In function 「void* Fib_gen(void*)」: Fib_Pthreads_4.cpp:15: 錯誤:從類型 「void*」 到類型 「const char*」 轉換無效 Fib_Pthreads_4.cpp:15: 錯誤: 初始化引數 1,屬於 「int atoi(const char*)」 可是這個 int num = atoi(param); 是照課本打進去的 請問bug出在哪邊 感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.191
james732:int num = atoi((char *)param); 140.117.171.46 04/07 11:12
star1327p:感謝 140.112.4.191 04/07 11:30
freesamael:c++編譯器對轉型要求比較嚴格一點 140.124.182.92 04/07 18:43