Hi all does anyone know how to do a directory listing in C? Also how I can include program parameters. Thanks!
For your first question, it depends entirely upon your system. For your second, you need to explain what you mean. Have a look here, both posts.
Yes it is possible to do directory listing using C. I hope this will suffice. No need for explaination ! Code: #include <stdio.h> #include <dir.h> int main(void) { struct ffblk ffblk; int done; printf("Directory listing of *.*\n"); done = findfirst("*.*",&ffblk,0); while (!done) { printf(" %s\n", ffblk.ff_name); done = findnext(&ffblk); } return 0; } struct ffblk is a structure storing all the relevant parameters required to list a directory. Use help in C for more details. findnext function call returns the next file in the directory Comments as always welcomed !
[COMMENT]Have the code block's when you have code snippets in the posts - http://www.go4expert.com/misc.php?do=bbcode#code[/COMMENT]