Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void main(int argc, char *argv[]) {
- int file = open("data.txt", O_WRONLY | O_APPEND);
- char bufor[1024];
- memset(&bufor[0], 0, sizeof(bufor));
- char znak[1];
- int licznik = 0;
- char output[1024];
- if(file != 0)
- {
- while(1)
- {
- read(0,znak,1);
- if(znak[0] == 27)
- {
- licznik = sprintf(output, "%s", bufor);
- write(file, output, licznik);
- break;
- }
- bufor[licznik] = znak[0];
- licznik++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement