ifinox

23.01 PP

Jan 23rd, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     int i, j, odp;
  8.     FILE *p;
  9.     printf("wybierz: 1 zapis\t2 odczyt\n");
  10.     scanf("%d", &odp);
  11.  
  12.     char liczby[3][20];
  13.     char litera[20];
  14.  
  15.     switch (odp)
  16.     {
  17.         case 1:
  18.         p=fopen("znaki.txt","w");
  19.         for(i=65,j=1; i<=90; i++, j++)
  20.         {
  21.             fprintf(p,"%d\t%c", i,i);
  22.             if(j%3==0)
  23.                 fprintf(p,"\n");
  24.             else
  25.                 fprintf(p,"\t\t");
  26.         }
  27.         fprintf(p,"\n\n\t\t\tMALE LITERY\n");
  28.         for(i=97,j=1; i<=122; i++, j++)
  29.         {
  30.             fprintf(p,"%d\t%c", i,i);
  31.             if(j%3==0)
  32.                 fprintf(p,"\n");
  33.             else
  34.                 fprintf(p,"\t\t");
  35.         }
  36.         fprintf(p,"\n");
  37.         fclose(p);
  38.         break;
  39.         case 2:
  40.         {
  41.             char t[80];
  42.             p=fopen("znaki.txt","r");
  43.             while( !feof(p))
  44.             {
  45.                 fgets(t,80,p);
  46.                 if (t[0]==' ' || t[0]=='\t' || t[0] == '\n')
  47.                     continue;
  48.                 int a, b, c;
  49.                 char v1, v2, v3;
  50.                 sscanf(t, "%d %c %d %c %d %c", &a, &v1, &b, &v2, &c, &v3);
  51.                 printf("%d %d %d %c %c %c\n", a, b, c, v1, v2, v3);
  52.             }
  53.             fclose(p);
  54.             break;
  55.         }
  56.         default: printf("ERROR\n");
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment