473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to read all files present in a directory in C ?

vsk
Hai All,
How to read all files present in a directory in C ?.
Thanks,

Nov 14 '05 #1
5 6237
"vsk" <vs*****@yahoo.co.in> writes:
How to read all files present in a directory in C ?.


This is in the FAQ.

19.20: How can I read a directory in a C program?

A: See if you can use the opendir() and readdir() functions, which
are part of the POSIX standard and are available on most Unix
variants. Implementations also exist for MS-DOS, VMS, and other
systems. (MS-DOS also has FINDFIRST and FINDNEXT routines which
do essentially the same thing.) readdir() only returns file
names; if you need more information about the file, try calling
stat(). To match filenames to some wildcard pattern, see
question 13.7.

References: K&R2 Sec. 8.6 pp. 179-184; PCS Sec. 13 pp. 230-1;
POSIX Sec. 5.1; Schumacher, ed., _Software Solutions in C_
Sec. 8.
--
"When in doubt, treat ``feature'' as a pejorative.
(Think of a hundred-bladed Swiss army knife.)"
--Kernighan and Plauger, _Software Tools_
Nov 14 '05 #2
Ben Pfaff wrote:
"vsk" <vs*****@yahoo.co.in> writes:

How to read all files present in a directory in C ?.

This is in the FAQ.

19.20: How can I read a directory in a C program?

A: See if you can use the opendir() and readdir() functions, which
are part of the POSIX standard and are available on most Unix
variants. Implementations also exist for MS-DOS, VMS, and other
systems. (MS-DOS also has FINDFIRST and FINDNEXT routines which
do essentially the same thing.) readdir() only returns file
names; if you need more information about the file, try calling
stat(). To match filenames to some wildcard pattern, see
question 13.7.

References: K&R2 Sec. 8.6 pp. 179-184; PCS Sec. 13 pp. 230-1;
POSIX Sec. 5.1; Schumacher, ed., _Software Solutions in C_
Sec. 8.


Ben, a suggestion: also include the link to the
FAQ. Your reply doesn't inform the OP how to get
to the FAQ or where it came from. Hmmmm, kind of
like citing your references. ;-)
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Nov 14 '05 #3
"Thomas Matthews" <Th*************************@sbcglobal.net> wrote in
message news:41**************@sbcglobal.net...
Ben, a suggestion: also include the link to the
FAQ. Your reply doesn't inform the OP how to get
to the FAQ or where it came from. Hmmmm, kind of
like citing your references. ;-)


I'm all for helping folks, but imo the 'hand holding'
can get out of hand, causing some to view the regulars
here as virtual servants. Anyone can type "C FAQ" into
google and find it. Ben did give the FAQ item number
with his quotation.

[insert that stuff about fish and feeding folks]
-Mike
Nov 14 '05 #4
In article <no****************@newsread3.news.pas.earthlink.n et>, Mike
Wahler <mk******@mkwahler.net> wrote:
"Thomas Matthews" <Th*************************@sbcglobal.net> wrote in
message news:41**************@sbcglobal.net...
Ben, a suggestion: also include the link to the
FAQ. Your reply doesn't inform the OP how to get
to the FAQ or where it came from. Hmmmm, kind of
like citing your references. ;-)


I'm all for helping folks, but imo the 'hand holding'
can get out of hand, causing some to view the regulars
here as virtual servants. Anyone can type "C FAQ" into
google and find it.


Such behaviour also helps keep the 'elect' and the mere rabble
separate. What's more important? To help those who need it, or to show
disdain for those who don't know what you happen to know?

FAQ's are very often concerned with netiquette and topical definitions;
and I for one had not assumed there was a collection of 'those' sort of
frequent questions about C.

However if this (suggested by Google)

http://www.eskimo.com/~scs/C-faq/faq.html

was what you were talking about, it wouldn't open.

neither would this (suggested by Google)

http://www.eskimo.com/~scs/C-faq/questions.htmll

nor this (suggested by Google)

http://www.lysator.liu.se/c/c-faq/

However, I did have better luck with this:

http://www.cdc.gov/ncidod/diseases/hepatitis/c/faq.htm

Is this what you meant? I'm tempted to add 'FAQED'.
Another Newcomer
Nov 14 '05 #5
Newcomer wrote:

In article <no****************@newsread3.news.pas.earthlink.n et>, Mike
Wahler <mk******@mkwahler.net> wrote:
"Thomas Matthews" <Th*************************@sbcglobal.net> wrote in
message news:41**************@sbcglobal.net...
Ben, a suggestion: also include the link to the
FAQ. Your reply doesn't inform the OP how to get
to the FAQ or where it came from. Hmmmm, kind of
like citing your references. ;-)


I'm all for helping folks, but imo the 'hand holding'
can get out of hand, causing some to view the regulars
here as virtual servants. Anyone can type "C FAQ" into
google and find it.


Such behaviour also helps keep the 'elect' and the mere rabble
separate. What's more important? To help those who need it, or to show
disdain for those who don't know what you happen to know?

FAQ's are very often concerned with netiquette and topical definitions;
and I for one had not assumed there was a collection of 'those' sort of
frequent questions about C.

However if this (suggested by Google)

http://www.eskimo.com/~scs/C-faq/faq.html

was what you were talking about, it wouldn't open.


I think the server's down.
Try again later.

--
pete
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris | last post by:
I need to monitor a bunch of files to see what is being opened, read, and closed, with no modifications being made. This is being done first on Windows machines, and later on Solaris. Looking...
2
by: Amy L. | last post by:
I am working on some code that will be used in a Windows Service that will monitor specific files in a queue. I would like to get an integer value of the amount of specfic files in a directory. ...
4
by: Rob Meade | last post by:
Hi all, I have just put together our organisations 'template' for our web applications and have created 7 .ascx files which when dropped into my template file work perfectly...however, I have a...
4
by: who be dat? | last post by:
I feel stupid for asking this but I can't figure this out. I've got some text files I want my website to read. The text files are located in a subdirectory of my application. Physically, the...
5
by: rbt | last post by:
What is the most efficient way to recursively remove files and directories? Currently, I'm using os.walk() to unlink any files present, then I call os.walk() again with the topdown=False option...
10
by: MLH | last post by:
I wish to give someone an A97 database they can install on their PC as a runtime application. I want them to click a button on a form (frmDocumentMyPC). I want to document as much useful...
6
by: learnerofpython | last post by:
hi! i have a directory structure(can be of any type) I want to search for the files present in it and extract the names of those files(file can be of any format e.g .txt/.c/.py) How can...
4
by: Jim | last post by:
I have the following piece of code: Directory.CreateDirectory(myDir); DirectoryInfo lDir = new DirectoryInfo(myDir); lDir.Attributes = FileAttributes.Normal; When this code runs, my directory...
1
by: Claire | last post by:
Ive written a small string resource building utility that I send out to our translators. I have a setup project for each language we support, which picks out a group of 12 english resx files plus...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.