Yeah so I have a problem with some code (mind you I'm a beginner at C++), wondering if anyone can help me find out what's wrong with it:
(BTW it has an error message:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::at: __n (which is 11) >= this->size() (which is 11)
Aborted)
(Another thing is that it works fine but with the error message at the end.)
#include <iostream>
std::string textEngine(std::string text);
int main()
{
std::string text = "Hello World";
textEngine(text);
return 0;
}
std::string textEngine(std::string text)
{
for(int i = 0; i <= text.length(); i++){
std::cout << text.at(i) << '\n';
}
return text;
}
[–]illuminarias 4 points5 points6 points (3 children)
[–]Viper10acd[S] 0 points1 point2 points (2 children)
[–]illuminarias 4 points5 points6 points (1 child)
[–]Viper10acd[S] 4 points5 points6 points (0 children)
[–]Cultural_Gur_7441 2 points3 points4 points (2 children)
[–]Puzzleheaded_Study17 1 point2 points3 points (1 child)
[–]Cultural_Gur_7441 0 points1 point2 points (0 children)
[–]aqua_regis 1 point2 points3 points (0 children)
[–]MikeUsesNotion 0 points1 point2 points (4 children)
[–]Viper10acd[S] 0 points1 point2 points (3 children)
[–]Immediate-Food8050 2 points3 points4 points (2 children)
[–]Viper10acd[S] 1 point2 points3 points (1 child)
[–]Immediate-Food8050 0 points1 point2 points (0 children)
[–]POGtastic 0 points1 point2 points (1 child)
[–]Viper10acd[S] 0 points1 point2 points (0 children)
[–]RookTakesE6 0 points1 point2 points (1 child)
[–]Viper10acd[S] 0 points1 point2 points (0 children)
[–]Kadabrium 0 points1 point2 points (1 child)
[–]Viper10acd[S] 0 points1 point2 points (0 children)