I am trying to open a file of integers that will be passed into a struct that holds an array, but when I try to do so I get an added zero in the output, and when I added more to my program the core is just dumped, so I'm not sure what I'm doing wrong and how to fix it.
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
using namespace std;
struct Hand
{
  int handCards[52];
  int totalCards;
};
struct Card
{
  char rank;
  char suit;
};
void OpenFile (ifstream&, string&);
void ReadFile (ifstream&, Hand&);
void ProcessRank (Hand&, int CardRank[]);
void ProcessSuit (Hand&, int CardSuit[]);
char GetRank (int);
char GetSuit (int);
void PrintCard (Card);
Card ConvertRaw (Hand);
void PrintHand (Card, Hand);
int main()
{
  ifstream inf;
  string filename;
  Hand theHand;
  Card aCard;
  int CardRank[13];
  int CardSuit[4];
  OpenFile(inf, filename);
  ReadFile(inf, theHand);
}
void OpenFile (ifstream &inf, string &filename)
{
  cout<<"What is the name of the file?" <<endl;
  cin>>filename;
  inf.open(filename.c_str());
  if (inf.fail())
    {
      cout<<"Sorry, that file doesn't exist" <<endl;
      exit(1);
    }
  else
    cout<<"Success!" <<endl <<endl;
}
void ReadFile (ifstream &inf, Hand &theHand)
{
  theHand.totalCards=0;
  int i=0;
  while(inf.good())
    {
      inf>>theHand.handCards[i];
      theHand.totalCards++;
      cout<<theHand.handCards[i];
      i++;
    }
}
The file is 123456, but then I get 1234560> as the output, and when I add in the rest of my code comes the core dump. I'm not sure if it's a problem passing or if my variables are off somehow, but it would mean a lot if someone can help me out.
 
     
    