Advertisement
visoft

Pointeri cu structuri

Oct 29th, 2020
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. /*
  6.  
  7.  *
  8.  */
  9.  
  10. typedef struct{
  11.     int aa;
  12. }NrComplex;
  13.  
  14. typedef struct{
  15.     int primul_termen,y;
  16. }NrComplex2;
  17.  
  18. #define TAB_SIZE 120
  19. #define TAB_SIZE2 1000
  20. void lucru_cu_tabel(NrComplex *ptr, int n){
  21.     //printf("Nr octeti: %d\n", sizeof(ptr));
  22.     for(int i=0;i<n;i++)
  23.         scanf("%d", &ptr[i].aa);
  24. }
  25.  
  26. int main() {
  27.     int i;
  28.     int tab[TAB_SIZE];
  29.     int * ptrtab = (int*)malloc(sizeof(int) * TAB_SIZE2);
  30.     printf("sizeof(tab): %d\n", sizeof(tab));
  31. //    lucru_cu_tabel(ptrtab, 3);
  32. //    printf("i= %d\n", i);
  33.  
  34.     NrComplex a2;
  35.     NrComplex2 *a3 = (NrComplex2*)malloc(sizeof(NrComplex2)*10);
  36.     (*a3).primul_termen;
  37.     a3->primul_termen; // a3[0].primul_termen
  38.     a3[2].primul_termen;
  39.  
  40.  
  41.  
  42.     return 0;
  43. }
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement