Originally Posted by
jimblumberg
Do you realize that your C++ version is no longer doing the same thing as the C version, even if you fix the logic errors in the C version?
I have no idea how it works under the hood. I only know it is now acting like a 1d array because one no longer has to reference both whatever them [ ] <<--- are called.
Code:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector < string > snackos =
{ " ", "Cracker Jacks","Gummy Bears","Lemon Heads",
"Skittles","Snickers","Milky Way"};
int count = 1;
for ( ; count < 7 ; count++)
cout <<snackos[count]<<endl;
cout<<"\n"<<snackos[4]<<endl;
//last line prints out the 5th element starting from zero,
// after the loop has ened.
//Is it properly placed within the code?
// Some would say no. But the compiler won't complain about it as
//much as some humans might.
return 0;
}
that much I know.