Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5.  
  6.  
  7. typedef struct {
  8.  
  9.     int* int1;
  10.  
  11.     char* char1;
  12.  
  13. } numeros_s;
  14.  
  15.  
  16.  
  17. void loadSettings(//char fileName [], struct configParam* paramsReaded [], int* length,
  18.  
  19.     numeros_s* num[]){
  20.  
  21.     // (*num) = (int*) malloc(sizeof(int));
  22.  
  23.     // (*num)[1] = 1;
  24.  
  25.     // (*num)[5] = 5;
  26.  
  27.     (*num) = malloc(sizeof(numeros_s)*5);
  28.  
  29.     (*num[0]).int1 = malloc(sizeof(int));
  30.  
  31.     *num[0]->int1 = 5;
  32.  
  33.     //(*num)[1].int1 = malloc(sizeof(int));
  34.  
  35.     *(num+1)->int1 = 10;
  36.  
  37.  
  38.  
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45. int main(){
  46.  
  47.     numeros_s* i;
  48.  
  49.     printf("%p\n", i);
  50.  
  51.  
  52.  
  53.     loadSettings(&i);
  54.  
  55.     printf("%d\n", *i[0].int1);
  56.  
  57.     return 0;
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement