title: Return chain of char - getgrouplist in C
body: <p>I have problem with returned char. I know that I had to allocate memory and assign to the tab if it was a string.But it is a char. I don't know which side i should go: create double array (char * tab[numbers of char][numbers of words]) or try concatenation. Function have to return chain of characters
  ( for example : [user, root, sudo] ).</p>
  
  <p>Here is my function:</p>
  
  <pre><code>char * groupsName(char *ut ){ //ut it's a user nick
  struct group *gr;
  int i;
  struct passwd *pw;
  gid_t *groups;
  int ngroups=0;
  char * tab= malloc ( sizeof (char) * ngroups)
          pw =getpwnam(ut);
          if(getgrouplist(ut, pw-&gt;pw_gid, groups, &amp;ngroups)&lt;0){
              groups=malloc(ngroups *sizeof(gid_t));
              getgrouplist(ut, pw-&gt;pw_gid, groups, &amp;ngroups);
  
             for(i=0;i&lt;ngroups;i++){
                  gr=getgrgid(groups[i]);
                  if(gr!= NULL)  tab[i] = gr-&gt;gr_name; 
              }
          return *tab;
          }   
  </code></pre>
  
  <p>} </p>