I have a c program that watches over a folder somewhere in your directory (location is given when program starts up). One of its tasks is to tell the user what contents are stored in that specified folder. I was thinking of piping the ls command but I'm unsure how to get contents of a folder in which you are not currently in. Help?
Thanks!
Just use ls?
ls /path/to/directory
Alternatively, use opendir()
and readdir()
, see man 3 opendir
and man 3 readdir