Can any one tell me how to make a function that returns an array of characters in C? A simple question that I can not solve. Do I need to declare pointer to return another array?
Can any one tell me how to make a function that returns an array of characters in C? A simple question that I can not solve. Do I need to declare pointer to return another array?
Code:# include <stdio.h> # include <stdlib.h> void function (int *) ( int a = array [0]; tab [0] = array [1]; tab [1] = a; ) int main (void) ( int * a = array (5 * sizeof (* tab)); if (tab! = NULL) ( tab [0] = 0; tab [1] = 1; function (tab); printf ( "% d% d \ n", tab [0], tab [1]); ) return 0; )
To make a function that returns an array of characters you are not required to use the IsArray function to ensure that the procedure indeed returned an array. You have to use dynamic allocation. If a procedure returns a value of type Variant, you might want to check its contents before performing array operations.
The function returns the string that it send as a parameter.Code:char * string (char * ch) ( return ch; ) / * main * / printf (string ( "hello!"));
Bookmarks