Why does this function crash?

I'm sorry about the question but I have been studying this for a while and can't figure out where the error is. This is a translator function that should be able to get words from getline and then match them with another array of words the index of which returns the translated word. The function crashes before it reaches the end however.

No, I'm certain that is correct. There are 805 numEntries and I need to search through all of them to find the correct English word.

So, if we assume that numEntries is 805 as you say it is, which of the entries does englishWord[numEntries] refer to?

123456789

int main()
{
constunsigned numEntries = 2;
int array[2] = { 0, 2 } ;
// valid indices for array, which has 2 elements are 0 and 1.// so if I do array[numEntries] which is the element that I'm accessing?// neither - numEntries is an invalid index and out of bounds of our array.
}

You may also note that, even were numEntries a valid index, you would be comparing the same element of englishWord to the same word each iteration of the loop.

Your not making much sense to me. My lecturer pretty much supplied that piece of code for use which is why i'm confident it can be applied. Why would numentries not be a valid index? numEntries = 2 would return the third result. I don't see why it would not.

arrays start at index 0 and if you use the same index each time the value will not change in cire's example in array positon 0 or array[0] is the number 0 and positon 1 is the number 2 there is no positon 2 that would mean you have an array size of 3
look at this linkhttp://www.cplusplus.com/doc/tutorial/arrays/

What everyone is trying to point out to you is that numEntries is accessing some value out-of-bounds of the array you want to check.

From cire's example:

12

constunsigned numEntries = 2;
int array[2] = {0,2};

And then what you just stated:

numEntries = 2 would return the third result. I don't see why it would not.

array in cire's example only has two items. What are you accessing if you attempt to get the third item?

In the same way, you current code is accessing a value just beyond the array's bounds and you do it a numEntries times.

12345678910111213

for(int I = 0; I < 805; I++){ //Let's go ahead and substitute your number to see what happens//Note that you don't use the variable I anywhere in this blockif (strcmp(englishWord[805], fullWord)==0)
{ //So now you access some value at position 805 when englishWord only goes up to 804; //englishWord at position 0 counts as the first position
cout << fullWord;
out_s = elvishWord[805]; //Let's go out of bounds again
}
/*Another thing to note that everyone else has tried telling you
is that you are accessing the same position for each iteration. You
are not iterating through each word.
*/
}