I'm in an introductory CS course and our task is to build the best ideal boggle board (one that would get you the most points). We are allowed to use arrays, c-strings, and reference parameters (no structs/pointers since we are just starting to learn about those).
Step one: I built my boggle board with randomly generated letters. (It is not part of this source file, I made another source specifically to try to read in a dictionary).
Step two: Read in a dictionary. I'm trying to output it to make sure it works, however, that is not part of the program, so as soon as I see it outputs I'll be taking that part of the code out.
I'm stuck on the second part of my program. Everytime I run this code I get "ConsoleApplication4.exe has stopped working".
I am using MSVS 2012 on Windows 7 with 12GB RAM and i7-930 CPU (idk if this matters).
Can someone tell me what I am doing wrong and how I can fix it? The dictionary.txt file is in the same file as the source file. Thanks alot!
#include <iostream>
#include <cstring>
#include <fstream>
#include <cassert>
using namespace std;
const int Size = 17; // 16 characters for the line + 1 for the '\0'
const int MaxNumberOfWords = 253633; // maximum number of words to be stored
int main()
{
ifstream inStream; // declare an input stream for my use
char theWords[MaxNumberOfWords][ Size]; // Array to store words from input line
int wordRow = 0; // Row for the current word
inStream.open( "dictionary.txt");
assert( ! inStream.fail() ); // make sure file open was OK
// Keep repeating while input from the file yields a word
while (inStream >> theWords[wordRow])
wordRow++;
// Go through the array of words, displaying each one in turn.
// Note that we only display the words read, not the empty array
// rows.
cout << "\n\n";
for (int i=0; i < wordRow; i++)
cout << i << ". " << theWords[ i] << endl; // display this word
cout << "Done.\n";
return (0);
}