Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #define taille_b 10
- int main(int argc, char** argv){
- char* invitation = "\nVeuillez entrer des caracteres :";
- char buffer[taille_b+1] = "\0";
- char message[31];
- int nbCar;
- if(write(1,invitation,strlen(invitation)) != strlen(invitation)){
- perror("Erreur d'ecriture");
- exit(10);
- }
- while(nbCar = read(0,buffer,taille_b)){
- if(nbCar == -1){
- perror("Erreur de lecture");
- exit(20);
- }
- if(buffer[nbCar-1] != '\n'){
- while(getchar() != '\n');
- }
- buffer[nbCar] = '\0';
- sprintf(message,"\nAppel systeme lu : %s\n",buffer);
- if(write(1,message,strlen(message)) != strlen(message)){
- perror("Erreur d'ecriture");
- exit(10);
- }
- if(write(1,invitation,strlen(invitation)) != strlen(invitation)){
- perror("Erreur d'ecriture");
- exit(10);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement