Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(char **argc, int argv) {
- automaton am;
- char word[WORD_SEND_LEN];
- int read_dsc, buf_len;
- if (argv != 2)
- printf("Usage: %s <read_fd>\n", argc[0]);
- read_dsc = atoi(argc[1]);
- printf("Reading data from descriptor %d\n", read_dsc);
- if ((buf_len = read(read_dsc, &am, sizeof(automaton))) == -1)
- perror("Error in read");
- if (buf_len == 0)
- perror("Unexpected end-of-file");
- else
- wypisz_automat(am);
- if ((buf_len = read(read_dsc, &word, WORD_SEND_LEN - 1)) == -1) {
- perror("Error in read");
- }
- else {
- word[buf_len < WORD_SEND_LEN - 1 ? buf_len : WORD_SEND_LEN - 1] = '\0';
- printf("dostalem slowo: %s.\n", word);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement