Advertisement
Josif_tepe

Untitled

May 27th, 2024
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. int main(int argc, char * argv[]) {
  6.     if(argc < 2) {
  7.         printf("Vlezna datoteka se vnesuva preku komandna linija\n");
  8.         return 0;
  9.     }
  10.     FILE * in = fopen(argv[1], "r");
  11.     if(in == NULL) {
  12.         printf("Vnesovte ne validna vlezna datoteka\n");
  13.         return 0;
  14.     }
  15.     char niza[2000];
  16.     char c;
  17.     int j = 0;
  18.     while((c = fgetc(in)) != EOF) {
  19.         if(isalnum(c)) {
  20.             niza[j] = c;
  21.             j++;
  22.         }
  23.         else {
  24.             if(isdigit(niza[0])) {
  25.                 for(int i = 0; i < j; i++) {
  26.                     printf("%c", niza[i]);
  27.                 }
  28.                 printf("\n");
  29.             }
  30.             j = 0;
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement