Problem with code (C++)

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:

#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;
}

Posted Jul 6, 2026, 8:59 PM UTC

122
Loading comments…