I am trying to access files in a folder. The folder name and location will be given - the program will search inside the files in that folder for a specific pattern(yup like grep). However, I am not sure how to actually let my program know what are the files available and access them one by one.
I could use pipe in unix or linux. As for Win XP I could only think of using the system("dir > tmpfilename") and thus saving the output it into a temporary file. Then taking the file names from that file.
Please let me know if anyone of you have a better idea as how to do the job. I cannot use win32 because the program would be used as an example in a class introducing the C programming language. So it means no C++ as well. Is there any way to make the code portable(I doubt)?