Advertisement
visoft

Problema 4.6 Iteratia Create

Nov 9th, 2020
2,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. // 4.6
  4.  
  5. typedef struct {
  6.     int *tab;
  7.     int capacitate;
  8.     int index;
  9. }Vector;
  10.  
  11. Vector create(){
  12.     Vector t;
  13.     t.capacitate = 2;
  14.     t.index = 0;
  15.     t.tab = (int*)malloc(sizeof(int) * t.capacitate);
  16.     return t;
  17. }
  18.  
  19.  
  20. int main() {
  21.  
  22.     Vector  v = create();
  23.    
  24. //    add(v, 10);
  25. //    add(v, 20);
  26. //    add(v, 30);
  27. //    add(v, 40);
  28. //    for (int i = 0; i < v.index;i++){
  29. //        printf("tab[%2d] = %d\n", i, get(v, i));
  30. //    }
  31.  
  32.  
  33.     return 0;
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement