I'm trying to save filenames into an array of chars.
My code seems incorrect, but can't figure out what's wrong :\
Code:char** get_categories(void) { DIR* dp; struct dirent* ds; char** cat; int i=1; dp = opendir("rubrieken/"); ds = readdir(dp); while(ds!=NULL) { if ( (strcmp(ds->d_name, ".") > 0) && (strcmp(ds->d_name, "..") > 0)) { realloc(cat, (i++)*sizeof(char)*strlen(ds->d_name)); cat[i-1] = malloc(sizeof(char)*strlen(ds->d_name); strcpy(cat[i-1], ds->d_name); } ds = readdir(dp); } return cat; }



LinkBack URL
About LinkBacks


