Problem with array.

So I have array that is up to 299 elements... but for some reason it when I run it.. i get an error stating "access violation writing location 0x976d4047.. and I believe it too be a memory issue as when I remove the 299th one it works fine.. any idea what could be causing this issue?


#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
using namespace std;

int random;
int main()
{
srand(time(0));
random = (rand() % 299) + 1;
cout<<"Welcome to the random word generator currently filled with 298 words!";
string wordlist[298];
...................
wordlist[296]="enjoy";
wordlist[297]="smash";//works up until this part
wordlist[298]="spice";//crashes at this part
Last edited on
the location wordlist[298] does not exist. the 298 locations are:
[0], [1], [2], .... [297].
Don't know why I didn't see that. Thanks.
Topic archived. No new replies allowed.