B
B
billy_herington2021-07-28 15:53:06
C++ / C#
billy_herington, 2021-07-28 15:53:06

What happens to memory?

Is there a function that returns a pointer to an array, after it has completed, the memory itself will be released?

char* func()
{
  char* arr = (char*)malloc(100);
  //
 // 
 return arr;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Antony, 2021-07-28
@billy_herington

Of course not.
The memory will hang in the "busy" heap until someone calls free() on it.

A
Armenian Radio, 2021-07-28
@gbg

Here comes the old-old song of the Mumiy-Troll group - Run away .

A
Adamos, 2021-07-28
@Adamos

It's not C++, it's C.
C++ has smart pointers for such tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question