Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to return char* from function in c++

//Function declaration
char* testfunc()
{
    char* str = malloc(10 * sizeof(char));
    return str;
}

//Calling the function
foo = testfunc();
// Do something with your foo
free(foo);		//It is required to free() memory to avoid memory lead
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #function
ADD COMMENT
Topic
Name
4+6 =