473,387 Members | 1,497 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,387 software developers and data experts.

Searching directories using C++

hi, can anyone tell me how to search a given directory using C++?


so far i have been successful in searching a file named, for tags"h:\\tags.cpp",
whereas i would like to search for all files in the entire h: directory.

this is the code i have used for searching the file named, "h:\\tags.cpp",

/*char filename[120];
cout<<"Please enter the filename";
cin>>filename;*/
char str[2000];
string stt;
//fstream file_op(filename,ios::in);
fstream file_op("h:\\tags.cpp",ios::in);

if(file_op.is_open())
{
while(!file_op.eof())
{
file_op.getline(str,2000);
cout<<str<<endl;
stt+=str;
}
file_op.close();

cout <<endl;
}
else
cout << "cannot open file" << endl;

im using Dev-CC++ 4.9.9.2 on Win XP Pro


many thanks
Apr 20 '07 #1
2 2060
sicarie
4,677 Expert Mod 4TB
neilio2j-

There is no "standard" way of doing this due to different operatins systems and versions, etc..., however, the ways I found for WinXP are:

using the osdir.h library
using the win32 API
or using one of boost.org's libraries.

I personally don't have much experience with this (I'm a Linux guy), but I'm sure others here do, and can help with the easisest/their favorite...
Apr 20 '07 #2
thanks for that ive tried running the code for the osdir.h file but my version (4.9.9.2) of C++ wont compile the code

i get a build error, can anyone tell me what this is?

here is the compiler log
{
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\NO ENTRY\My Documents\University Stuff\Software\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\NO ENTRY\My Documents\University Stuff\Software\Makefile.win" all
g++.exe -o "Project1.exe" -L"C:/Dev-Cpp/lib"

g++.exe: no input files

make.exe: *** [Project1.exe] Error 1

Execution terminated
}

thanks
Apr 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John | last post by:
Hi everyone ! This is a first time I post a message here. If I post my message in a wrong group. Please ignore it. I am trying to build a website which allows users (can be thousands of...
0
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web...
6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
5
by: Alan Mackenzie | last post by:
I've recently moved onto a C++ project with a large number of directories (several hundred) containing an even larger number of C++ source files. There are vastly more ways in C++ to obfuscate a...
2
by: Jeffry van de Vuurst | last post by:
Hi, (sorry for the crosspost, I wasn't sure which was the best place to put this). I was just thinking about something and wondered if any of you has some ideas about this. I'm using the...
29
by: jaysherby | last post by:
I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can...
1
by: souravmallik | last post by:
Hello, I'm writing a parser program in C language. I need to search all the source file for the parser to parse from a set of directories. The directory structure have two branch i.e. there...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
4
by: jodleren | last post by:
Hi! I wonder, which way to do this fastest. I have a disk, where I need to search for a file or directory. I do it recursively, meaning that I start from the top dir, then I add all...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.