I have the following code that I need to figure out what the output will be. Whenever I try to run it I get an debug error - and it crashes... Somebody else said that it ran fine on their Apple machine. I just need to see what the output will be:
Thanks
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void PlayWithStrings(vector<string> InVec)
{
static int i = 8;
if (i != -1)
{
if (i == 7 || i == 6)
cout << InVec[i];
i--;
PlayWithStrings(InVec);
}
if (i == -1)
{
cout << "for Sure! ";
i = 0;
}
}
int main(int argc, const char * argv[])
{
vector<string> ForwardString;
ForwardString.reserve(8);
vector<string>::iterator VItr = ForwardString.begin();
ForwardString.insert(VItr, "This "); VItr++;
ForwardString.insert(VItr, "is "); VItr++;
ForwardString.insert(VItr, "the "); VItr++;
ForwardString.insert(VItr, "way "); VItr++;
ForwardString.insert(VItr, "to "); VItr++;
ForwardString.insert(VItr, "an "); VItr++;
ForwardString.insert(VItr, "A "); VItr++;
ForwardString.insert(VItr, "Grade ");
for (VItr = ForwardString.begin(); VItr != ForwardString.end(); VItr++)
cout << *VItr;
cout << "- ";
PlayWithStrings(ForwardString);
return 0;
}