title: Trying to create an array of Struct and load data from file
body: <p>I have this struct i created called User which stores all kind of data,
  now i'm trying to create an array of it (User*) and get data from a file,
  this is what i do in the start of my main program:</p>
  
  <pre><code>int amount = 0;
  User* users = NULL;
  
  // read from file functions
  loadUsers(&amp;users,&amp;amount);
  </code></pre>
  
  <p>And the function (the amount of users is the first line of my txt file):</p>
  
  <pre><code>void loadUsers(User** users,int* amount2){
      int amount, i = 0, j;
      char temp[STRING_SIZE], temp2[STRING_SIZE];
      FILE* f;
  
      f = fopen("input.txt", "r");
  
      if (!f){
          return;
      }
  
      if (fileEmpty(f)){
          return;
      }
  
      fscanf(f, "%d", &amp;amount);
      *amount2 = amount;
  
      *users = malloc(sizeof(User)*amount);
      /**users = (User*)malloc(sizeof(User)*amount);*/
  
      while (!feof(f)){
          fscanf(f, "%s", temp);
          users[i]-&gt;ID = (char*)malloc(sizeof(char)*(strlen(temp) + 1));
          strcpy(users[i]-&gt;ID, temp);
          fscanf(f, "%s", temp);
          users[i]-&gt;f_name = (char*)malloc(sizeof(char)*(strlen(temp) + 1));
          strcpy(users[i]-&gt;f_name, temp);
          fscanf(f, "%s", temp);
          users[i]-&gt;l_name = (char*)malloc(sizeof(char)*(strlen(temp) + 1));
          strcpy(users[i]-&gt;l_name, temp);
  
          i++;
      }
  </code></pre>
  
  <p>For some reason i get an error and while debugging i see the allocation is wrong since i only have <code>users[0]</code> and not <code>users[1]</code>, like an array of users should have, even when the amount is higher than 1.</p>
  
  <p>My target is to have an array, which each cell of it is a User.</p>
  
  <p>What could be the reason?</p>
  
  <p>Edit:
  User struct:</p>
  
  <pre><code>struct User{
      char* ID;
      char* f_name;
      char* l_name;
      int age;
      char gender;
      char* username;
      char* password;
      char* description;
      char** hobbies;
  }typedef User;
  </code></pre>