title: Reading and storing ints with scanf in C
body: <p>I have a text file that looks like this:</p>
  
  <pre><code>1 2 4
  3 5 2
  9 7 6
  4 2 6
  </code></pre>
  
  <p>of an unknown size upto 50 lines.</p>
  
  <p>I am trying to store the ints in an array of struct</p>
  
  <pre><code>typedef struct column{
  int col_1;
  int col_2;
  int col_3;
  } column;
  </code></pre>
  
  <p>I have created the array of stuct column</p>
  
  <pre><code>column column[50];
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  
  FILE * myfile;
   int i = 0;
  
  if ((myfile = fopen("/home/numbers.txt","r"))==NULL)
  {
      printf("File %s not found\n", "/home/numbers.txt");
      exit(0);
  }
  if ("/home/numbers.txt" == NULL)
  {
      printf("There was an error reading %s", "/home/numbers.txt");
  
  }
  
  while(fscanf(myfile,"%d %d %d", &amp;column[i++].col_1, &amp;column[i].col_2, &amp;column[i].col_3) == 3)
  {
     printf("\n%d %d %d", column[i].col_1, &amp;column[i].col_2, &amp;column[i].col_3);
  }  
  </code></pre>
  
  <p>I get a list of numbers like this</p>
  
  <pre><code>    -420921 -420924 -420927
  </code></pre>
  
  <p>It appears to be some memory addresses, because they are obviously not the actual numbers. </p>
  
  <p>My problem is the get the ints rather than some rather random numbers, i have tried &amp; before the variables in the printf, and that didnt work, and the other way around. </p>
  
  <p>Your help would be greatly appreciated.</p>