Do you need to sort the data? If you're just listing all the files, think about it like this
Code:
while there is still entries in the directory
print the entry
endwhile
Its that easy. Look into opendir(3) and readdir(3). If you need to sort the data it becomes a little trickier. For instance, entries in directories are not sorted by default, even though you see them in order when you run ls. So you need to think of a way to sort this. I would read the results into a data structure, sort it, then print the results. You dont know the number of entries, so you would have a tough time making an array of proper size. *hint* use a linked list, or dynamic array.
Code:
while there is still entries in the directory
append entry to data structure
endwhile
sort data structure
print data structure
You'll to research at least:
opendir
readdir
stat (if you want to implement ls -l type functionality)
See you're man pages. Also a book on Linux/UNIX programming would help. Or online books. Theres no shortage of documentation available.