title: How to return a defined type (array) from a function?
body: <p>I get an error, when I try to return a value of type verylongint from a function. What is the correct way to return?
  verylongint is an array of the type long long int and is defined in line 5.
  the function returning a verylongint should be string2verylongint(char* n).  The output of the compiler is below the source code.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #define SIZE 63
  
  typedef long long verylongint[63];
  
  char* verylongint2string(verylongint n);
  verylongint string2verylongint(char* n);
  
  main(){
      verylongint n;
      int i;
      for(i=0; i&lt;SIZE; i++)n[i]=0; //initialize
      n[0]= 999999999999999999;
      n[1]= 999999999999999999;
      n[2]= 2323232311;
      printf("%s\n", verylongint2string(n));
  
      verylongint m;
      m = string2verylongint("123999999999999999999999999999999999999999999999999999999");
  
      printf("%s\n", verylongint2string(m));
  }
  
  verylongint string2verylongint(char* n){
      char m[18]; // first long long element, which is not zero, as string
      sscanf(n, "%[^9]", m);
      long long n1; // as long long
      sscanf(m, "%lld", &amp;n1);
      int length= strlen(n)-strlen(m); // length of string without the first element
      int i;
      verylongint k; //return value
      for(i=0; i&lt;SIZE; i++)k[i]=0; //initialize
      for(i=0; i&lt;length/18; i++){ // length/18 is the number of elements (without 1st)
          k[i]=999999999999999999;
      }   
      k[i] = n1;
  
      printf("%s\n", verylongint2string(k));
  
      return k;
  }
  
  char* verylongint2string(verylongint n){
      char* string = (char*) malloc(18*63*sizeof(char));//18 is the length of the biggest number
                              //63 is the length of the long-array
      int i=SIZE;
      while(n[--i]==0);
      //string=n[i];
      sprintf(string, "%lld", n[i]); //first number, which is not zero
      while(--i&gt;=0){ //adding the biggest number
          strcat(string,"999999999999999999"); //the biggest number(one char smaller than lld)
      }
  
      return string;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>user@user-VirtualBox:~/Documents$ gcc verylongint.c -o vli
  verylongint.c:9:13: error: ‘string2verylongint’ declared as function returning an array
   verylongint string2verylongint(char* n);
               ^
  verylongint.c: In function ‘main’:
  verylongint.c:21:4: error: incompatible types when assigning to type ‘verylongint’ from type ‘int’
    m = string2verylongint("123999999999999999999999999999999999999999999999999999999");
      ^
  verylongint.c: At top level:
  verylongint.c:26:13: error: ‘string2verylongint’ declared as function returning an array
   verylongint string2verylongint(char* n){
               ^
  verylongint.c: In function ‘string2verylongint’:
  verylongint.c:42:2: warning: return makes integer from pointer without a cast [enabled by default]
    return k;
    ^
  verylongint.c:42:2: warning: function returns address of local variable [-Wreturn-local-addr]
  </code></pre>