Advertisement
Guest User

ettv etility

a guest
Apr 26th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void)
  5. {
  6.     //usleep(500000);
  7.     FILE*in=fopen("players.txt","r");
  8.     FILE*out=fopen("players.cfg","w");
  9.     FILE*help=fopen("phelp.cfg","w");
  10.     if (!in) {puts("Not found.");return 1;}
  11.     char name[50];
  12.     int id;
  13.     char c;
  14.     char flag=0;
  15.  
  16.     while (!feof(in))
  17.     {
  18.         if (!flag) fgets(name,50,in);
  19.         //printf("%s",name);
  20.         if (fscanf(in,"%d: ",&id)&&flag)
  21.         {
  22.         fgets(name,50,in);
  23.         if (strstr(name," total players\n")) break;
  24.         *strchr(name,'\n')=0;
  25.         printf("%s\n",name);
  26.         }
  27.         else fgets(name,30,in);
  28.         if (!flag&&strstr(name,"----------")) {flag=1;}
  29.     }
  30.     puts("-----------------------------------");
  31.     flag=0;
  32.     fseek(in,0,SEEK_SET);
  33.     while (!feof(in))
  34.     {
  35.         if (!flag) fgets(name,50,in);
  36.         if (fscanf(in,"%d: ",&id)&&flag)
  37.         {
  38.         fgets(name,50,in);
  39.         if (strstr(name," total players\n")) break;
  40.         *strchr(name,'\n')=0;
  41.         printf("%s ",name);c=getc(stdin);if (c!='\n') getc(stdin);
  42.         //printf("BIND %c follow %d\n",c,id);
  43.         if (c==' ') break;
  44.         if (c!='\n') fprintf(out,"BIND %c follow %d\n",c,id);
  45.         if (c!='\n') fprintf(help,"echo \"BIND %c follow %d\"\n",c,id);
  46.         }
  47.         else fgets(name,30,in);
  48.         if (!flag&&strstr(name,"----------")) {flag=1;}
  49.     }
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement