hi.....
how to get all path names all files
in a perticular directory in C pgm.
plz tell me...and give some sample pgm.
hi.....
how to get all path names all files
in a perticular directory in C pgm.
plz tell me...and give some sample pgm.
Hi,
'pgm' means programme I guess...
You can find information on the standard library functions here:
http://www.gnu.org/software/libc/man...Directory.html
Ahhm...the path name for all files in a particular directory would be:
particular_directory(/ or \)file
You don't even need a c program!
But if you meant "all path names (...) in a particular directory" (which would be the directories in the directory, I guess), you could look at dirent.h and readdir. You can get the file type of each file this way and determine if it is a directory.
If this gives you trouble, post to this thread again.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
There's an FAQ about this, with an example of readdir() and friends, I believe.
http://faq.cprogramming.com/cgi-bin/...&id=1044780608
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Example:
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char buffer[256]; printf("Input a directory name: "); fgets(buffer, sizeof(buffer)/2, stdin); strtok(buffer, "\n"); snprintf(buffer + sizeof(buffer)/2, sizeof(buffer)/2, "ls \"%s\"", buffer); system(buffer + sizeof(buffer)/2); return 0; }
That's just painful. You should put that code in your signature instead of the mere two-plus-buffer-overflow code.
[edit] I especially like
Very well done. [/edit]Code:strtok(buffer, "\n");
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I shouldn't post code like that anymore. I am sometimes taken dangerously seriously and receive PMs such as "Code works great, but how do I capture its output?"