title: First-chance exception at 0x00998876 in Project4.exe: 0xC0000005: Access violation writing location 0x00000000
body: <p>I am writing a hangman game. I cannot proceed with debugging because I do not understand this error: </p>
  
  <blockquote>
    <p>First-chance exception at 0x00998876 in Project4.exe: 0xC0000005:
    Access violation writing location 0x00000000. Unhandled exception at
    0x00998876 in Project4.exe: 0xC0000005: Access violation writing
    location 0x00000000.</p>
  </blockquote>
  
  <p>This is where the error is being generated:</p>
  
  <pre><code>void Player::getWords()
  { 
    ifstream WordBank;
    int index=0;
    WordBank.open("C:\\WordBank\\words.txt");
  
    if(WordBank)
    {
        for(index=0;index&lt;100;index++)
        {     
             WordBank&gt;&gt;Words1[index];     
        }
        WordBank.close();
    }
    else
    {
        cout&lt;&lt;"There was an error."&lt;&lt;endl;
    } 
  }
  </code></pre>
  
  <p>The Words array is declared as a member variable.</p>
  
  <p>Here is my code. I am not yet sure how formatting words and I am trying to finish this program.</p>
  
  <pre><code>class Player
  {   public:
      string fName;
       string lName;
       int DOB;
       string username;
       int SS4;
       string email;
       int won;
       int lost;
       const int static  WordSIZE=15;
       int const static totalWORDS=100;
       string static Letters[WordSIZE];
       string static  Words1[totalWORDS];
       char static   Copy[WordSIZE];
       char static Guess[WordSIZE];
       int index;
       int word;
       int size;
       int isComing;//I need function to initialize these.
       char letter;
       bool correct;//I need a function to initialize these.
       string Word1;
  public:
      Player(string,string,int,string,int,string);
      void getWords();
      void boardSetup();
      void playGame();
      void deathBed(int);
  
  
  
  };
  
  Player::Player(string first,string last,int birth, string nicname,int SS,string mail)
  {
   fName=first;
   lName=last;
   DOB=birth;
   username=nicname;
   SS4=SS;
   email=mail;
   isComing=0;
   correct=true;
  }
      const int static  WordSIZE=15;
       int const static totalWORDS=100;
    string Player::  Words1[totalWORDS]; 
      char Player::   Copy[WordSIZE];
       char Player:: Guess[WordSIZE];
        string Player:: Letters[WordSIZE];
   void Player::getWords()
  { 
  
  
  
  
  
    ifstream WordBank;
    int index=0;
      WordBank.open("C:\\WordBank\\words.txt");
  
  
      if(WordBank)
      {
           while(WordBank&gt;&gt;Words1[index])
           {
             index++;
           }
       WordBank.close();
      }
      else
          {
            cout&lt;&lt;"There was an error."&lt;&lt;endl;
          }
  
  }
  
  
      /*string *words2;
      words2=new  string[100];
    ifstream WordBank;
    int index;
      WordBank.open("C:\\WordBank\\words.txt");
  
  
      if(WordBank)
      {
         for(index=0;(WordBank&gt;&gt;words2[index]);index++)
          {
  
  
  
          }
      WordBank.close();
      }
      else
          {
            cout&lt;&lt;"There was an error."&lt;&lt;endl;
          }
      delete [] words2;
     words2=0;
  }*/
  
  void Player::boardSetup()
  {
      unsigned seed =time(0);
      srand(seed);
      word=rand()%100;
      Words1[word]=Word1;
      strcpy_s(Copy,Word1.c_str());
  
      size=strlen(Word1.c_str());
      for(index=0;index&lt;size;index++)
      {
          Guess[index]='-';
          cout&lt;&lt;Guess[index]&lt;&lt;endl;
      }
  
  
  }
  
  
  
  
  
  
  
  }
  
  void Player::playGame()
  {
      while(isComing!=7)
      {
          deathBed(isComing);
          cout&lt;&lt;Guess&lt;&lt;endl;
          cout&lt;&lt; "Please guess a letter."&lt;&lt;endl;// or press 0 to go to the main screen for help
          cin&gt;&gt;letter;
          letter=toupper(letter);
  
              for (index=0;index&lt;size;index++)
          {
              if(Copy[index]==letter)
              {
                 cout&lt;&lt;"Nice Job"&lt;&lt;endl; //add the ability to see the word
                 Guess[index]=letter;
                 cout&lt;&lt;Guess[index]&lt;&lt;endl;
  
              }
              else  if(strcmp(Word1.c_str(),Guess)==0)
                {
                    cout&lt;&lt;"You WIN!!!"&lt;&lt;endl;
                    return;
                }
  
              else if (correct=false)
              {
                  cout&lt;&lt;"Please,Try again"&lt;&lt;endl;
                  isComing++;
              }
          }
  
      }
       void deathBed(int isComing);
  
       cout&lt;&lt;"The word is"&lt;&lt;Words1[word]&lt;&lt;"."&lt;&lt;endl;
  
       //draw a big red noose. call a function for it.
  
  }
  
  
  struct userInfo
  {
      string FName;
      string LName;
      int dob;
      string Username;
      int ss4;
      string Email;
  };
  
  userInfo getUserInfo();
  
  
  int main()
  { 
    userInfo i; 
       i=getUserInfo();
   Player player1(i.FName,i.LName,i.dob,i.Username,i.ss4,i.Email);
   player1.getWords();
   player1.boardSetup();
   player1.playGame();
  
      return 0;
  }
  
  userInfo getUserInfo()
  {
      userInfo info;
  
      cout&lt;&lt;"What is your first name?"&lt;&lt;endl;
      cin&gt;&gt; info.FName;
      cout&lt;&lt;"What is your last name?"&lt;&lt;endl;
      cin&gt;&gt;info.LName;
      cout&lt;&lt;"What is your date of birth"&lt;&lt;endl;
      cin&gt;&gt;info.dob;
      cout&lt;&lt;"Please enter a user name."&lt;&lt;endl;
      cin&gt;&gt;info.Username;
      cout&lt;&lt;"Please enter the last four digits of your Social Security number."&lt;&lt;endl;
      cin&gt;&gt;info.ss4;
      cout&lt;&lt;"Please enter your email address."&lt;&lt;endl;
      cin&gt;&gt;info.Email;
  
      return info;
  }
  </code></pre>