Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void write_data(FILE *stream) {
- int i;
- for (i = 0; i < 100; ++i) {
- fprintf(stream, "%d\n", i);
- }
- if (ferror(stream)) {
- fprintf(stderr, "Output to stream failed.\n");
- exit(-1);
- }
- fclose(stream);
- }
- int main() {
- FILE *output;
- output = popen("less", "w");
- if (!output) {
- fprintf(stderr, "Incorrect parameters or too many files.\n");
- exit(-1);
- }
- write_data(output);
- if (pclose(output) != 0) {
- fprintf(stderr, "Could not run more or other error.\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement