#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>

int main(int argc, char *argv[]) {
struct dirent *de_table[100];
DIR *d1;
int i, cols;

cols = (argc == 1) ? 1 : atoi(argv[1]);
if (cols <= 0 || cols > 100) cols = 1;

d1 = opendir(".");

do {
	for (i = 0; i < cols; i++)
		de_table[i] = readdir(d1);
	for (i = 0; i < cols; i++) 
		printf("%-15.15s ", (de_table[i] == NULL) ? "" : de_table[i]->d_name);

	putchar('\n');
}
while(de_table[0] != NULL);

closedir(d1);
return 0;
}


