Message from C, C++ talks

October 2020

— Sry sry I didn't see it someone had send a msg that his mood was damn fucking and I replied u instead of someone else

Message permanent page

— Facing problem with compiler

— Dude.
Ask the question.
Not 5 messages, 1 consise message, ok?

— Good day.

I have the following problem I hope you can help me:

Inside a function (fun_a) I am creating a lamda function to use as a callback when calling another function (fun_b).
Inside the lambda function I use a variable defined in the fun_a function.
After calling the fun_b function there is a waiting time, however if this time passes the fun_a function ends.
If after the function fun_a ends the lambda function is executed, a crash is generated since the variable no longer exists since function fun_a has already finished.

Message permanent page



It throws the following error with input as "123":
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::at: __n (which is 18446744073709551615) >= this->size() (which is 3)
Aborted (core dumped)

Can anyone spot any kind of mistake?

— C++ compiler errors are so cryptic. Hate it

— They are not

— They are for me

— I am still learning C++, bear with me man 😅

— Just saying 🙃

— Sure, no biggy

— Anyone sees anything?

— You have whats called index error in other languages

— Seems like an integer overflow

— Are you trying to use list[-1] or something?