I assume you already know how to use terminal (probably in a terminal emulator inside graphical environment). I also assume you have C programming experience. For many things in Linux you can get documentation using "man" command. So run the following commands:
man 3 opendir
man 3 readdir
man 2 stat
Numbers 2 and 3 specify manual page type (wrappers for kernel calls and library functions of the libc, respectively); they are optional, but "man stat" finds "man 1 stat" - documentation for a shell command. Printing can be done with "printf" just fine.
After you have read the documentation, you can ask more specific questions.