All pastes #2047455 Raw Edit

Unnamed

public text v1 · immutable
#2047455 ·published 2011-04-17 16:37 UTC
rendered paste body
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <dirent.h>


int main() {

  char **strings;
  struct dirent *entry;
  DIR *tDir;
  int i = 0;

  strings = malloc(sizeof(char**));

  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++;
      strings = realloc(strings, sizeof(char*)*i);
      strings[i] = entry->d_name;
  }

  closedir(tDir);

  return 0;
}