c - Will this leak memory? -


I have created a small function to cat out the strings and return the combined string. However since I assign memory to a third variable in the function, then the memory will be freed if the function is over, or will it need to be released later after it remains there? And if I need to free it, then what is the most stylish solution to do?

Here is a test code that works, but I can not tell whether this memory is free from my devices or not.

  #include & lt; Stdio.h & gt; # Include & lt; Math.h> #include & lt; String.h & gt; Four * stracket (CONST FOUR * ST1, CONST FOUR * ST2) {FOUR * STRUG = CALLK ((STLAN (CT1) + STRELAN (CT2) + 1), SACHOFF (four)); Dome (string, whistle 1); Dome (string, stat 2); Return string; } Int main () {printf ("string:% s \ n", straight ("hello", "world"); Return 0; }  

Yes you have to make it free.

Maybe something like:

  int main () {char * s = StrCat ("hello", "world"); Printf ("string:% s \ n", s); Free (s); Return 0; }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -