0
У меня есть простой поток, который печатает числа, и проблема в том, что поток печатается на scanf. Что-то вроде того.c - scanf прервано, и printf в потоке
input> DATAOFTHREAD
, но я хочу, чтобы напечатать результат что-то вроде этого
DATAOFTHREAD
input>
можно? какую функцию я должен использовать? Это мой код:
#include <stdio.h>
#include <pthread.h>
void *connection_handler(void* data) {
int i = (int)data;
for(i=0;i<5;i++) {
printf("%d", i);
fflush(stdout);
}
pthread_exit(NULL);
}
int main()
{
int t;
int x;
int rc;
pthread_t thread_id;
rc = pthread_create(&thread_id, NULL, connection_handler, (void *)x);
if(rc) {
printf("Error en pthread()\n");
return 1;
}
printf("Ingresa un numero: ");
scanf("%d", &t);
printf("%d\n", t);
pthread_exit(NULL);
return 0;
}
Благодаря
Ох, спасибо ...: D – user3720124