title: When should I use scanf with the address of '&' ampersand key?
body: <p>I have to read in a text file with names and numbers. The names represent candidates in a dummy election (7 in total) and the numbers represent the voters. If the voter number is not in the range of the 7 candidates it gets thrown out but still stored. Finally, I have to print out the results of who won the election and how many spoilt votes there were.</p>
  
  <p>This is my text file:</p>
  
  <pre><code>Robert Bloom 
  John Brown 
  Michelle Dawn 
  Michael Hall 
  Sean O’Rielly 
  Arthur Smith 
  Carl White 
  
  3 8 1 3 1 6 12 9 6 5 0 2 8 4 
  6 6 8 3 2 8 0 12 6 1 8 3 2 2 
  3 2 5 7 4 11 8 6 11 12 11 7 5 5 
  8 9 10 12 1 3 12 12 9 11 7 9 3 1 
  2 10 12 7 11 9 6 6 0 1 10 7 11 2 
  8   0 12 8 10 11 2 2 8 4 2 12 3 2 
  9   1 4 8 8 7 7 4 12 2 10 10 9 4 
  12 9 3 12 0 4 8 0 6 5 9 0 5 3 
  11  6   0   3   0 
  </code></pre>
  
  <p>This is where I am stuck about how to scan these in properly</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  FILE * data;
  int spoilt=0;
  
  typedef struct
  {
   int votes;
   char name[20];
  }candidates;
  
  void initialize( candidates *electionCandidates, FILE *data )
  {
      int i;
      for( i=0; i&lt;7; i++ )
      {
          fscanf( data, "%[^\n]%*c", electionCandidates[i].name );
          printf( "%s\n", electionCandidates[i].name );
          electionCandidates[i].votes=0;
      }
  
  }
  
  int processVotes( candidates *electionCandidates, FILE *data )
  {
      int i;                                           //tallying votes
      int voter;
      for ( i = 0; i&lt; 365; i++ )
      {
         fscanf( data, "%d", voter );
         if ( voter &lt;= 7&amp;&amp; voter &gt; 0 )
          electionCandidates[voter-1].votes++;
         else
          spoilt++;
      }
  
                                                      //catcher to grab winner
      int maxValue, winner=0;
  
      maxValue = electionCandidates[0].votes;
      for( i = 0; i &lt; 7; i++ )
      {
          if( maxValue &lt; electionCandidates[i].votes )
          {
              maxValue = electionCandidates[i].votes;
              electionCandidates[winner] = electionCandidates[i];
          }
  
      }
  
      return electionCandidates[winner], maxValue;
  
  
  }
  
  void printResults( candidates *electionCandidates )
  {
      printf("%s won the election with a total of %d votes.\n There was a total of %d spoilt"
              electionCandidates[winner].name, maxValue, spoilt);
  
  }
  
  
  int main() {
      data = fopen( "elections.txt","r" );
      candidates electionCandidates[7];
  
      initialize( electionCandidates, data );
      processVotes( electionCandidates, data );
      printResults( electionCandidates );
  
  
      fclose( data );
      return 0;
  }
  </code></pre>