Kackhaufen200

task1_client.c

Apr 18th, 2020
257
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <string.h>
  7. #include <fcntl.h>
  8. #include <stdbool.h>
  9.  
  10. int main(int argc, char** argv){
  11.     char choice[1000];
  12.     int fifo_server;
  13.     bool help = true;
  14.     char path[50];
  15.  
  16.     printf("\n");
  17.     printf("Messages:\n");
  18.  
  19.     while(help){
  20.         strcpy(path, "/tmp/chat/");
  21.         strcat(path, argv[1]);
  22.         fifo_server = open(path, O_WRONLY);
  23.         fgets(choice, sizeof(choice), stdin);
  24.         write(fifo_server, choice, sizeof(choice));
  25.         close(fifo_server);
  26.     }
  27.     return EXIT_SUCCESS;
  28. }
RAW Paste Data