Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct{
- int a,b;
- char *c,*d;
- }ZAZNAM;
- void nacitaj(ZAZNAM *** z, int len){
- int i =0;
- while(scanf("%d",(*z[i])->a) != EOF){
- if(i<len){ //ak je pole plne tak sa zvecsi
- ZAZNAM **tmp = malloc(len*100*sizeof(ZAZNAM*));
- for(int j;j<len;j++){
- tmp[j] = malloc(sizeof(ZAZNAM));
- 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
- }
- *z = tmp; //presuniem z na novy str;
- }
- (*z[i])->c = malloc(100);
- (*z[i])->d = malloc(100);
- scanf("%d",(*z[i])->b);
- scanf("%s",(*z[i])->c);
- scanf("%s",(*z[i])->d);
- i++;
- }
- }
- int main(){
- int len = 10;
- ZAZNAM **z = malloc(10* sizeof(ZAZNAM*));
- for(int i;i<len;i++){
- z[i] = malloc(sizeof(ZAZNAM));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement