Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Cpp :: find index of element in array c++ 
Cpp :: c++ cout format 
Cpp :: create copy constructor c++ 
Cpp :: c++ array rev pointer 
Cpp :: how to code string to int converter c++ 
Cpp :: int to hexadecimal in c++ 
Cpp :: vector::insert 
Cpp :: iterate over vector in c++ 
Cpp :: palindrome program in c++ 
Cpp :: 58. Length of Last Word leetcode solution in c++ 
Cpp :: stoi() c++ 
Cpp :: c++ vector resize 
Cpp :: See Compilation Time in c++ Program 
Cpp :: Header for INT_MIN 
Cpp :: priority queue smallest first 
Cpp :: c++ namespace 
Cpp :: 2d vector in cpp 
Cpp :: if statement c++ 
Cpp :: convert int to string in c++ 
Cpp :: c++ Program to check if a given year is leap year 
Cpp :: quicksort geeksforgeeks 
Cpp :: binary search in c++ 
Cpp :: Give an algorithm for finding the ith-to-last node in a singly linked list in which the last node is indicated by a null next reference. 
Cpp :: c++ get last element in vector 
Cpp :: c++ changing string to double 
Cpp :: c++ vector first element 
Cpp :: how to declare a vector of int in c++ 
Cpp :: convert wchar_t to to multibyte 
Cpp :: C++ linked list iterator 
Cpp :: how to make loop in c++ 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =