title: Pass a string in a struct to a function and return it
body: <p>I want to return the name of the smallest city population-wise, if it is the second city. (Please don't mind the if statement, I know it's bland), the missing return is what bothers me.</p>
  
  <p>I assume I should declare a pointer inside the function <code>rSmallestCity</code>, like <code>*rtrn</code> but I guess the source variable is destroyed before it is used?</p>
  
  <pre><code>typedef struct Coordinate{
      int x,y;
  }Coordinate;
  
  typedef struct city{
      char name[20];
      int population;
      Coordinate coordinates;
  }city;
  
  char *rSmallestCity(city **cl, int n)
  {
       char *rtrn = NULL;
       if(cl[n-2]-&gt;population&gt;cl[n-1]-&gt;population)
       {
           rtrn = &amp;cl[n-1]-&gt;name;
       }
       return rtrn;
  }
  
  int main()
  {
      city c1 ={.name="Mumbai", .population=310, .coordinates.x=3, .coordinates.y=4};
      city c2 ={.name="Delhi", .population=300, .coordinates.x=3, .coordinates.y=2};
      city *clist[2];
      clist[0]=&amp;c1;
      clist[1]=&amp;c2;
      printf("\n%s is smallest\n",rSmallestCity(clist,2));
  }
  </code></pre>
  
  <blockquote>
    <p>warning: assignment to 'char <em>' from incompatible pointer type 'char (</em>)[20]' [-Wincompatible-pointer-types]|</p>
  </blockquote>