[問題] Pthreads 內 使用 atoi
大家好 想要請問關於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
→
04/07 11:12, , 1F
04/07 11:12, 1F
→
04/07 11:30, , 2F
04/07 11:30, 2F
推
04/07 18:43, , 3F
04/07 18:43, 3F