#whaat
24 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
@serene sleet
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
l is 2 or 1 so it should print something
yet it doesnt print anything
I'm not a complete noob i sort of know what i m doing but now I'm just super mad an astonished liie wtff
This code is undefined behavior
ret[i] doesn't exist.
It seems to work, but you are breaking rules that can result in horrible crashes
Try with a longer string and see for yourself
wdym it doesnt exist? do u mean i need to allocate for it? I thought u need not do it with cpp string class
I mean as long as l is string's length nothing bad should happen right?
Im seminoob
plz explain 😄
@serene sleet You're doing out of bounds access on ret
ret.size() is 0, you aren't allowed to touch any characters at index >= ret.size()
You do. What you want is ret.push_back(str[i]);
It just happens to seem to work because of some implementation details for std::string
Ooooh I see thanku
.push_back adds to the end and will allocate as necessary.
oh my god yes
cpp is stupid
time to go back to C
SOLVED LOL