SHARE
TWEET

Untitled

razvanth21 Nov 28th, 2018 (edited) 7 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int v1[100], v2[100];
  5. int j, k;
  6.  
  7. void read(FILE *f)
  8. {
  9.     if (f)
  10.     {
  11.         char str[192], *p;
  12.         char aux_str1[128];
  13.         int aux_nr1, aux_nr2;
  14.         int i = 0;
  15.  
  16.         while (fgets(str, sizeof(str), f))
  17.         {
  18.             p = strtok(str, " ");
  19.  
  20.             while (p)
  21.             {
  22.                 if (i == 3) // aici in p vine ceva de genul: 44315/MAIN;0
  23.                 {
  24.                     if (sscanf(p, "%d/%[^;\n];%d", &v1[j++] ,aux_str1, &v2[k++]))
  25.                         fprintf(stdout, "%d, %d\n", v1[j], v2[k]);
  26.  
  27.                     break;
  28.                 }
  29.  
  30.                 i ++;
  31.                 p = strtok(NULL, " ");
  32.             }
  33.  
  34.             i = 0;
  35.         }
  36.     }
  37. }
  38.  
  39. int main(void)
  40. {
  41.     FILE *f = fopen("test.txt", "r");
  42.  
  43.     if (!f)
  44.         exit(-1);
  45.  
  46.     read(f);
  47.     fclose(f);
  48.     return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top