I want to print out the contents of a vector in C++, here is what I have:
#include
#include
#include
#include
I see two problems. As pointed out in for (x = 17; isalpha(firstsquare); x++)
there's either an infinite loop or never executed at all, and also in if (entrance == 'S')
if the entrance character is different than 'S' then nothing in pushed to the path vector, making it empty and thus printing nothing on screen. You can test the latter checking for path.empty()
or printing path.size()
.
Either way, wouldn't it be better to use a string instead of a vector? You can access the string contents like an array as well, seek characters, extract substrings and print the string easily (without a loop).
Doing it all with strings might be the way to have it written in a less convoluted way and easier to spot the problem.