Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main(int argc, char * argv[]) {
- if(argc < 4) {
- printf("Nema dovolno argumenti\n");
- return 0;
- }
- FILE * in = fopen(argv[1], "r");
- FILE * out_parni = fopen(argv[2], "w");
- FILE * out_neparni = fopen(argv[3], "w");
- if(in == NULL || out_neparni == NULL || out_parni == NULL) {
- printf("Ne postecki fajlovi\n");
- return 0;
- }
- int i = 0;
- char niza[2000], c;
- while((c = fgetc(in)) != EOF) {
- if(isalpha(c)) {
- niza[i] = c;
- i++;
- }
- else {
- if(i % 2 == 0) {
- for(int j = 0; j < i; j++) {
- fprintf(out_parni, "%c", niza[j]);
- }
- fprintf(out_parni, " ");
- }
- else {
- for(int j = 0; j < i; j++) {
- fprintf(out_neparni, "%c", niza[j]);
- }
- fprintf(out_neparni, " ");
- }
- i = 0;
- niza[0] = '\0';
- }
- if(c == '\n') {
- fprintf(out_neparni, "\n");
- fprintf(out_parni, "\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment