Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                             Online C Compiler.
  4.                 Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. typedef struct{
  13.     int a,b;
  14.     char *c,*d;
  15. }ZAZNAM;
  16.  
  17. void nacitaj(ZAZNAM *** z, int len){
  18.     int i =0;
  19.     while(scanf("%d",(*z[i])->a) != EOF){
  20.         if(i<len){                                              //ak je pole plne tak sa zvecsi
  21.             ZAZNAM **tmp = malloc(len*100*sizeof(ZAZNAM*));
  22.             for(int j;j<len;j++){
  23.                 tmp[j] = malloc(sizeof(ZAZNAM));
  24.                 if(j<i)memcpy(tmp[j],z[j],sieof(ZAZNAM*));      // kopirovanie stareho pola do noveho  malo by fungovat ak nie proste sa spravi velky if kde das vsetky atr pojednom skopcis
  25.             }
  26.             *z = tmp;                                           //presuniem z na novy str;
  27.         }
  28.         (*z[i])->c = malloc(100);
  29.         (*z[i])->d = malloc(100);
  30.         scanf("%d",(*z[i])->b);
  31.         scanf("%s",(*z[i])->c);
  32.         scanf("%s",(*z[i])->d);
  33.         i++;
  34.     }
  35. }
  36.  
  37. int main(){
  38.     int len = 10;
  39.     ZAZNAM **z = malloc(10* sizeof(ZAZNAM*));
  40.     for(int i;i<len;i++){
  41.         z[i] = malloc(sizeof(ZAZNAM));
  42.     }
  43.    
  44.    
  45.    
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement