1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include<stdlib.h>
#include<stdio.h>
#include<pthread.h>
#include<unistd.h>
char c;
//fonction pour lire des caractère
void *lecture(void *k)
{
printf("donner un caractère\n");
scanf("%s",&c);
while(c!='f' || c!='F')
{
printf("donner un caractère\n");
scanf("%s",&c);//l'erreur est ici
printf("\n");
}
}
void *ecriture(void *k)
{
while(c!='f' || c!='F')
{
printf("le caractere est :%c",c);
}
}
int main(void)
{
pthread_t pth[2];
if(pthread_create(pth,0,lecture,NULL))
{
perror("pthread_create");
exit(EXIT_FAILURE);
}
/*if(pthread_create(pth+1,0,ecriture,NULL))
{
perror("pthread_create");
exit(EXIT_FAILURE);
}*/
if(pthread_join(pth,NULL))
perror("erreur");
/*if(pthread_join(pth+1,NULL))
perror("erreur");*/
} |
Partager