Extra Unwanted data in an array
<p>When i go to print my array it prints, but there is extra data at the end. The Extra Data is one line after the last line of output that should be there. it contains:" -13096448" (note, it starts with a space.)</p>

<pre><code>/***************************************************/
/* Author:     Sam LaManna                         */
/* Course:                                         */
/* Assignment: Program 6 Elves                     */
/* Due Date:   12/9/11                            */
/* Filename:   program6.cpp                        */
/* Purpose:    Write a program that will process   */
/*             the work done by santas elfs        */
/***************************************************/

#include &lt;iostream&gt;     //Basic input/output
#include &lt;iomanip&gt;      //Manipulators
#include &lt;string&gt;       //String stuff 
#include &lt;fstream&gt;      //File input/output

using namespace std;

void instruct ();     //Function Declaration for printing instructions 
void input (ifstream &amp;infile, string &amp;names, int &amp;numoftoys);    //Function declaration for getting data from file
void headers ();     //Prints headers

int main()
{

  string names [50];       //Array for storing names
  int numoftoys [50];      //Array for storing the number of toys made
  int i = 0;
  int p = 0;

  ifstream infile("elves.dat"); //Opens input file "elves.dat"

  instruct();     //Function call to print instructions

  while (!infile.eof())
    {
      input (infile, names[i] , numoftoys[i]);
      ++i;
    }

  for (int p = 0; p&lt;i; p++)
    {
      cout &lt;&lt; names[p] &lt;&lt; " " &lt;&lt; numoftoys[p] &lt;&lt; "\n";
    }



  return 0;
}




/***************************************************/
/* Name: instruct                                  */
/* Description: Prints instructions to user        */
/* Parameters: N/A                                 */
/* Return Value: N/A                               */
/***************************************************/

void instruct ()                                   
{
  cout &lt;&lt; "\n" &lt;&lt; "This program will calculate the toys made by santas elfs and assign" &lt;&lt; "\n";
  cout &lt;&lt; "a rating to each elf. It will also sort them and print average, min and max." &lt;&lt; "\n";
  cout &lt;&lt; "\n" &lt;&lt; "Make sure you have a file named elves.dat in the same directory as";
  cout &lt;&lt; " this porgram or you will recieve errors.";
  cout &lt;&lt; "\n" &lt;&lt; "\n";

  return;
}


/***************************************************/
/* Name: input                                     */
/* Description: Reads from file                    */
/* Parameters: N/A                                 */
/* Return Value: N/A                               */
/***************************************************/

void input (ifstream &amp;infile, string &amp;names, int &amp;numoftoys)
{
  infile &gt;&gt; names;
  infile &gt;&gt; numoftoys;
  //  infile.ignore ('\n');

  return;
}
</code></pre>

<p>Data File: </p>

<pre><code>Smiley 662
Curley 88
Clementine 335
Jasper 105
Lucinda 775
Brunhilda 103
Florence 441
Oskar 820
Snowflake 990
Bernard 690
Punch 298
Chuckie 10
Frosty 102
Snowman 311
April 830
Merry 299
Sunshine 331
Buddy 1234
Carol 271
Misty 111
Harold 52
Henry 292
Twinkle 308
Starlight 703
Burr 112
Angelica 444
Bluenose 689
Harry 254
Twinkle 259
Stardust 121
Greensleeves 453
Noel 312
Happy 209
Yukon 534
Snowcap 190
Northpole 598
</code></pre>
