title: How to return array of char?
body: <p>I want to return char array from snd_mixer_selem_get_id function:</p>
  
  <pre><code>char* alsa_get_channel_name( void )
  {
      int err;
      snd_mixer_selem_id_t *sid;
      snd_mixer_elem_t *elem;
  
      if ((err = snd_mixer_open (&amp;handle, 0)) &lt; 0) {
              fprintf(stderr, "mixer: open error: %s\n", snd_strerror(err));
      }
      if ((err = snd_mixer_attach (handle, card)) &lt; 0) {
              fprintf(stderr, "mixer: attach error: %s\n", snd_strerror(err));
      }
      if ((err = snd_mixer_selem_register (handle, NULL, NULL)) &lt; 0) {
              fprintf(stderr, "mixer: register error: %s\n", snd_strerror(err));
      }
      if ((err = snd_mixer_load (handle)) &lt; 0) {
              fprintf(stderr, "mixer: load error: %s\n", snd_strerror(err));
      }
  
      snd_mixer_selem_id_alloca(&amp;sid);
  
      for (elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)) {
              if ((!snd_mixer_selem_is_active(elem))
                      continue;
  
              snd_mixer_selem_get_id(elem, sid);
              const char *name = snd_mixer_selem_id_get_name(sid);
              if (name)
                  sprintf(name, sizeof(name), "%s", snd_mixer_selem_get_name(elem));
      }
      snd_mixer_close(handle);
  
      return name;
  }
  </code></pre>
  
  <p>I don't know how to write line sprintf(name, sizeof(name), "%s", snd_mixer_selem_get_name(elem)); to return channel name.</p>
  
  <p>Thanks</p>