I'm trying to create a C console program that produces a directory listing (one filename per line) of all files matching a specified filename pattern. I'm kind of clueless as to where to start and was wondering if someone could give me a boost? I'm mainly a C++ coder but am required to code this in C...

Any tips and pointers would be much appreciated.

Thanks.

That is platform-dependent, what OS do you have? The easiest solution would probably just be to use the system() function with a console command that would do that for you, like "find" on *nix systems.

Edited 5 Years Ago by chrjs: n/a

That is platform-dependent, what OS do you have? The easiest solution would probably just be to use the system() function with a console command that would do that for you, like "find" on *nix systems.

I'm running Windows 7. The issue with coding this is that I only have C++ experience under my belt. And even under C++ I've never really dived into this realm of coding.

opendir/closedir/readdir is in POSIX, so should work with your operating system.

He's using Windows 7, not *nix. Windows 7 doesn't support those functions.

He's using Windows 7, not *nix. Windows 7 doesn't support those functions.

He is correct; those lines of code are not compatible with my OS. And thanks for all the replies! I should've mentioned this before but my program is not intended for cross platform--just Windows.

I'll give it a try and let you guys know! Thanks for all the help--really it means a lot!

J

MinGW can compile code for windows. Maybe even windows 7. I didn't try, I don't have any sympathy for the devil.
It's 2011, don't tell me windows doesn't speak posix...

>>don't tell me windows doesn't speak posix

It doesn't. MinGW is a port and the underlying code that runs under MS-Windows just calls win32 api functions. Most win32 api functions do not support posix.

But I agree with you that you should use MinGW if the program is to be ported between the two operating systems.

This article has been dead for over six months. Start a new discussion instead.