A
A
avo4632020-11-11 00:19:41
C++ / C#
avo463, 2020-11-11 00:19:41

Cleaning strings in a c++ function, is it necessary?

I asked myself this question, is it necessary to clear the lines inside the function, does this make sense?
for example:

std::string test(std::string object)
{
std::string new_object = object;
std::string request = request_server(SOME_HOST, new_object);

new_object.clear();

return request;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2020-11-11
@avo463

If you read the tutorial, you can find out what happens to local variables when a function exits.
And if you write in C ++ - the textbook is definitely worth reading.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question