Hi all, I wanted to create a program that will tell me how items I can push onto a string vector before the computer runs out of memory and crashes. Now I remember at uni we touched on Exceptions. And I think that that is what I need to be using. But I cant remember how to use them… below I have what I have tried to do so far, but it doesn’t seem to work.
Code:
vector<string> wordlist;
unsigned long long int count = 0;
try{
for(;;){
wordlist.push_back("wordblahhello");
count++;
throw count;
}
}
catch(unsigned long long int count){
cout << count << endl;
}