My program is crashing when I run it, I ran the debugger and it reports this:
std::out_of_range
at memory location 0x0066F6F4.
My code is as follows:
#include <iostream>
#include <string>
int main() {
std::string name = "Alexi";
for (unsigned int i = 0; i <= name.length(); i++) {
for (unsigned int x = 0; x <= i; x++) {
if (i == x) std::cout << name.at(x);
else std::cout << " ";
}
std::cout << '\n';
}
return 0;
}
Any help would be appreciated.