All pastes #2046092 Raw Edit

Someone

public text v1 · immutable
#2046092 ·published 2011-04-13 18:32 UTC
rendered paste body
int main() {
  struct dirent *entry;
  DIR *tdir;
  int i = 0, j = 0;
  char *dirs;

  tdir = opendir("/home/madlax");

  while (entry = readdir(tdir)) {
    if (entry->d_type != 4 || strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
      continue;

    i++;
  }

  closedir(tdir);

  dirs = new char[i];

  while (entry = readdir(tdir)) {
    if (entry->d_type != 4 || strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
      continue;

    dirs[j] = entry->d_name;
    j++;
  }

  return 0;
}