Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. typedef struct{
  4.     char kod[20+1];
  5.     float iznos;
  6.     int dan;
  7.     int mjesec;
  8.     int godina;
  9.     int sat;
  10.     int minuta;
  11.     int sekunda;
  12. }crypto;
  13.  
  14. /*char* ucitajPoruku()
  15. {
  16.     char* str = (char*) malloc(sizeof(char));
  17.  
  18.     *str = '\0';
  19.  
  20.     int n = 2;
  21.  
  22.     int key;
  23.  
  24.     char sup[2] = {'\0'};
  25.  
  26.     while((key = getc(stdin)) != '\n')
  27.     {
  28.         str = realloc(str, n * sizeof(char));
  29.  
  30.         sup[0] = (char) key;
  31.  
  32.         strcat(str, sup);
  33.  
  34.         n++;
  35.     }
  36.  
  37.     return str;
  38. }*/
  39.  
  40.  
  41. int main()
  42. {
  43.     char a[10][10];
  44.  
  45.     int n;
  46.     int m = -1;
  47.  
  48.     int i = 0, j;
  49.     int br = 0;
  50.  
  51.     crypto kripto[1000];
  52.  
  53.     FILE *fin = fopen("creepto.val", "rb+");
  54.  
  55.     FILE *fout = fopen("test.txt", "w");
  56.  
  57.     if(fin == NULL)
  58.         exit(1);
  59.  
  60.     for(i = 0; i < 4; i++)
  61.     {
  62.         scanf("%c", a[i]);
  63.  
  64.         if(strcmp(a[i], "6") == 0)
  65.             break;
  66.         if(strcmp(a[i], "3") == 0)
  67.             break;
  68.         if(strcmp(a[i], "p") == 0)
  69.             break;
  70.     }
  71.  
  72.     //a = ucitajPoruku();
  73.  
  74.     while(fread(&kripto[i], sizeof(crypto), 1, fin) == 1)
  75.         i++;
  76.  
  77.     br = i;
  78.  
  79.     fclose(fin);
  80.  
  81.  
  82.     for(i = 0; i < br; i++)
  83.     {
  84.         char *pch = strstr(kripto[i].kod, a[0]);
  85.  
  86.         if(pch)
  87.         {
  88.             pch = NULL;
  89.             pch = strstr(kripto[i].kod, a[1]);
  90.  
  91.             if(pch)
  92.             {
  93.                 pch = NULL;
  94.                 pch = strstr(kripto[i].kod, a[2]);
  95.  
  96.                 if(pch)
  97.                 {
  98.                     pch = NULL;
  99.                     pch = strstr(kripto[i].kod, a[3]);
  100.  
  101.                     if(pch)
  102.                     {
  103.                         printf("asd");
  104.                     }
  105.  
  106.                 }
  107.             }
  108.         }
  109.     }
  110.  
  111.  
  112.         /*if(br == strlen(a))
  113.         {
  114.             fprintf(fout,"%s@%.2d:%.2d:%.2d\n", kripto[i].kod, kripto[i].sat,
  115.                     kripto[i].minuta, kripto[i].sekunda);
  116.         }*/
  117.  
  118.  
  119.  
  120.  
  121.  
  122.     return 0;
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement