title: get list of file names and store them in array on linux using C
body: <p>is there any way to look for some file names with given pattern in a directory and store those names (probably in an array) in C on Linux?</p>
  
  <p>I tried the glob one but I dont know how to save the names besides just print them out..</p>
  
  <pre><code>glob_t g;
  g.gl_offs = 2;
  glob("*.c", GLOB_DOOFFS | GLOB_APPEND, NULL, &amp;g);
  g.gl_pathv[0] = "ls";
  g.gl_pathv[1] = "-l";
  execvp("ls", g.gl_pathv);
  </code></pre>