【发布时间】:2026-02-12 19:30:01
【问题描述】:
如何立即退出或停止线程?
当用户输入答案时,如何让它立即停止? 我希望它为每个问题重置。
这是我的涉及线程的代码
int q1() {
int timer_start;
char ans[] = "lol";
char user_ans[50];
timer_start = pthread_create( &xtimer,NULL,(void*)timer_func,(void*)NULL);
printf("What is the capital city of Peru?\n");
while(limit){
scanf("%s",user_ans);
if(limit)
{
if(!strcmp(user_ans, ans))
{
// printf("YAY!\n");
score++;
// q2();
}
else
{
game_over();
}
}
}
}
【问题讨论】:
标签: c multithreading pthreads