Advertisement
Guest User

mindig csak a tanulás 2. ZH

a guest
May 25th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 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[41];
  13. while(c=fgetc(f))
  14. {
  15.         if(c==';')
  16.            {
  17.            c=fgetc(f);
  18.            if(c=='I')
  19.                 volt_i=1;
  20.            }
  21.  
  22.         if(c=='\n' || c==EOF){
  23.            if(volt_i == 1)
  24.                 {
  25.                 db++;
  26.                 volt_i=0;
  27.                 }
  28. }if(c==EOF)
  29.     break;}
  30. printf("%d\n",db);
  31. rewind(f);
  32. while(c=fgetc(f) )
  33. {
  34.         if(c!=';' && elso_jel == 0)
  35.            nev[i++]=c;
  36.  
  37.         if(c==';')
  38.            {
  39.            elso_jel=1;
  40.            c=fgetc(f);
  41.            if(c=='I')
  42.                 volt_i=1;
  43.            }
  44.  
  45.        if(c=='\n' || c==EOF )
  46.            {
  47.            if(volt_i == 1)
  48.                 {
  49.                 nev[i]='\0';
  50.                 printf("%s\n",nev);
  51.                 }
  52.            volt_i=0;
  53.            i=0;
  54.            elso_jel=0;
  55.            }
  56. if(c==EOF)
  57.     break;
  58. }
  59. fclose(f);
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement