Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz program, który wywo ł a polecenie „sort nazwa.c”, gdzie nazwa.c jest
- nazwą pliku z kodem ź ród ł owym programu, a nast ę pnie odczyta 20 znaków
- zwróconych przez to polecenie i wy ś wietli je na ekran.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #define BUFFER_SIZE 20
- #define COMMAND "sort 01.c"
- int main(int argc, char *argv[])
- {
- char buffer[BUFFER_SIZE];
- FILE *file;
- if((file = popen(COMMAND, "r")) == NULL){
- perror("popen");
- return EXIT_FAILURE;
- }
- fread(buffer, sizeof(char), BUFFER_SIZE, file);
- buffer[BUFFER_SIZE] = '\0';
- printf("%s\n", buffer);
- if(pclose(file) == -1){
- perror("pclose");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement