Advertisement
Josif_tepe

Untitled

Jun 12th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6.  
  7. int main(int argc, char *argv[]) {
  8.     FILE *ti = fopen(argv[1], "r");
  9.     FILE *ki = fopen(argv[2], "r");
  10.     if(ti == NULL || ki == NULL) {
  11.         printf("Ne vnesovte validni datoteki! Probajte povtorno!\n");
  12.         return 0;
  13.     }
  14.     char niza[1000];
  15.     while(fgets(niza, 500, ti)) {
  16.         int x;
  17.         fscanf(ki, "%d", &x);
  18.         if(strlen(niza) < x) {
  19.             printf("\n");
  20.         }
  21.         else {
  22.             for(int i = 0; i < x; i++) {
  23.                 printf("%c", niza[i]);
  24.             }
  25.             printf("\n");
  26.         }
  27.     }
  28.     return 0;
  29. }
  30. /*
  31.  
  32.  **/
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement