Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. int main(char **argc, int argv) {
  2. automaton am;
  3. char word[WORD_SEND_LEN];
  4. int read_dsc, buf_len;
  5. if (argv != 2)
  6. printf("Usage: %s <read_fd>\n", argc[0]);
  7. read_dsc = atoi(argc[1]);
  8. printf("Reading data from descriptor %d\n", read_dsc);
  9.  
  10. if ((buf_len = read(read_dsc, &am, sizeof(automaton))) == -1)
  11. perror("Error in read");
  12.  
  13. if (buf_len == 0)
  14. perror("Unexpected end-of-file");
  15. else
  16. wypisz_automat(am);
  17.  
  18. if ((buf_len = read(read_dsc, &word, WORD_SEND_LEN - 1)) == -1) {
  19. perror("Error in read");
  20. }
  21. else {
  22. word[buf_len < WORD_SEND_LEN - 1 ? buf_len : WORD_SEND_LEN - 1] = '\0';
  23. printf("dostalem slowo: %s.\n", word);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement