Advertisement
Guest User

tejes

a guest
May 25th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.82 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. FILE *f;
  9. f=fopen(argv[1],"r");
  10.  
  11. int i=0,db=0,volt_i=0,elso_jel=0;
  12. char c,nev[42];
  13. while(c=fgetc(f))
  14. {
  15.         if(c==';')
  16.         {
  17.             c=fgetc(f);
  18.             if(c=='t')
  19.             {
  20.                 c = fgetc(f);
  21.                 if (c == 'e')
  22.                 {
  23.                     c = fgetc(f);
  24.                     if(c == 'j')
  25.                     {
  26.                         c = fgetc(f);
  27.                         if (c == ';')
  28.                         {
  29.                             volt_i=1;
  30.  
  31.                         }
  32.                     }
  33.                 }
  34.             }
  35.         }
  36.  
  37.         if(c=='\n' || c==EOF){
  38.            if(volt_i == 1)
  39.                 {
  40.                 db++;
  41.                 volt_i=0;
  42.                 }
  43. }if(c==EOF)
  44.     break;}
  45. printf("%d\n",db);
  46. rewind(f);
  47. while(c=fgetc(f) )
  48. {
  49.         if(c!=';' && elso_jel == 0)
  50.            nev[i++]=c;
  51.  
  52.         if(c==';')
  53.         {
  54.             elso_jel = 1;
  55.             c=fgetc(f);
  56.             if(c=='t')
  57.             {
  58.                 c = fgetc(f);
  59.                 if (c == 'e')
  60.                 {
  61.                     c = fgetc(f);
  62.                     if(c == 'j')
  63.                     {
  64.                         c = fgetc(f);
  65.                         if (c == ';')
  66.                         {
  67.                             volt_i=1;
  68.  
  69.                         }
  70.                     }
  71.                 }
  72.             }
  73.         }
  74.  
  75.        if(c=='\n' || c==EOF )
  76.            {
  77.            if(volt_i == 1)
  78.                 {
  79.                 nev[i]='\0';
  80.                 printf("%s\n",nev);
  81.                 }
  82.            volt_i=0;
  83.            i=0;
  84.            elso_jel=0;
  85.            }
  86. if(c==EOF)
  87.     break;
  88. }
  89. fclose(f);
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement