Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz program, który uruchomi polecenie „wc” i przeka ż e mu na standardowe
- wej ś cie dowolny ci ą g znaków.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc, char *argv[])
- {
- if(argc != 2){
- fprintf(stderr,"Podano za duzo lub za malo argumentow\nUzycie: %s [ciag znakow]\n", argv[0]);
- return EXIT_FAILURE;
- }
- FILE *file;
- char *string = argv[1];
- if((file = popen("wc", "w")) == NULL){
- perror("popen");
- return EXIT_FAILURE;
- }
- fwrite(string, sizeof(char), strlen(string), file);
- if(pclose(file) == -1){
- perror("pclose");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment