input all files from a folder

Is there an easy way to create a loop that reads files until there are no more files in a given folder (without knowing the file names or how many are in the folder)? So maybe a program that would return the first line of each file. Also, is there a way to restrict the program to only consider *.html? Thanks

Chris
There's no easy way to do it. How much complexity are you willing to add, and what system are you on?
i intrested in it too plz :) help i tryed to system(copy *.html c:\\here\\
but i dont know how to search and i dont know how can i "go" in 2 words folders cause he couldnt go in if i say to : copy c:\\one two\\ it doesnt know ?one two? cause of space
If your compiler supports dirent POSIX calls, the following links may help

(Normal)
http://www.cplusplus.com/forum/unices/12452/
http://www.cplusplus.com/forum/unices/12452/#msg60107

(Sorted)
http://www.cplusplus.com/forum/unices/3548/#msg15009

There is also the Boost Filesystem that can help you:
http://www.boost.org/doc/libs/1_43_0/libs/filesystem/doc/index.htm

Good luck!
This is unrelated to traversing directories, but to pass arguments with special characters (such as spaces) in them, surround them with quotes. This works on any shell.
Topic archived. No new replies allowed.