Modifying a char array inside a function in C - Array [ Glasses to protect eyes while coding : https://amzn.to/3N1ISWI ] Modifying a char array inside a fun. c - I need a read the file into an array but I have problem with the ... In C you cannot return an array directly from a function. Returning multidimensional arrays from a function in C - Array cpp by Amused Ape on Jun 30 2021 Comment. Thus, we can return a pointer to the first char element of that array by calling the built-in data () method. It's illegal in C++. The rand () function generates the random alphabets in a string and srand () function is used to seed the rand () function. You return an array via a pointer (possible embedded in a struct either as a pointer or an array). How to return a Pointer from a Function in C - GeeksforGeeks Initially, we have a program that sets the array of alphabets size as "ch_Max," which is of int char data type. Returning a Char Array from function in C - GameDev and int > len of string, the remaining spots are initialized to '\0'. Learn more about c#, matlab compiler, dll, unrecognized function or variable MATLAB Find the treasures in MATLAB Central and discover how the community can help you! neandron2 (3) Hello everyone! Then we define an 'integer' data type variable. I am passing and returning a char array wrong. Feb 7, 2013 at 3:04pm. Then I want to print it in main. 2. The character array is declared just like int and float data . 1. return s; } Depending on what you are trying to do, you'll probably want to use something like this. The array is either dynamically allocated in the function, or passed into the function as an argument and then returned again: char *f() { char *s = malloc(42); .