Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 109,725 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,913 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



need help on "Searching for the given type of file" using C

 
Reply to this topicStart new topic

need help on "Searching for the given type of file" using C

yunus_sys
post 18 Jul, 2008 - 04:10 AM
Post #1


New D.I.C Head

*
Joined: 15 May, 2008
Posts: 2

Hi,

I need a C program to search for the specific type of file in the specified drive. For example if I give file name as "test" it has to search for all the files with there starting name as "text" irrespective of the remaining characters. Also if I give file type extension as ".txt" it has to display all "txt" files in that location. Please help me. It’s an urgent.
User is offlineProfile CardPM

Go to the top of the page


gabehabe
post 18 Jul, 2008 - 05:23 AM
Post #2


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,644



Thanked 51 times

Dream Kudos: 1575

Expert In: (X)HTML, CSS, Batch Scripting, C, C++

My Contributions


It's an urgent what?

This is pretty simple if you put some thought into it.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM

Go to the top of the page

F!st!cuffs
post 18 Jul, 2008 - 08:18 PM
Post #3


New D.I.C Head

*
Joined: 15 Jul, 2008
Posts: 33



Thanked 1 times
My Contributions


why can't you just use search?
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 18 Jul, 2008 - 10:40 PM
Post #4


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,757



Thanked 20 times

Dream Kudos: 2800

Expert In: C, C++, VB, VB.NET, C#, Java, x86 Assembly, Win32 API, Reversing

My Contributions


What is your target platform?
If you're using Windows, use the findfirst() function from io.h.
Specify "*.txt" as the wildcard parameter and pass it as the first argument to the function.
User is offlineProfile CardPM

Go to the top of the page

yunus_sys
post 19 Jul, 2008 - 06:15 AM
Post #5


New D.I.C Head

*
Joined: 15 May, 2008
Posts: 2

Hi,

I have written this code, but it seems some thing wrong with this. Please help me to solve this. I want this application in DOS or windows environment. If possible please provide me the full coed.

Thanks a lot.

CODE

# include <stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char fname[12];
char first[8], ext[3], command[100];
int i=0;
clrscr();
printf("Enter file name : ");
scanf("%s",&fname);
// fflush(stdin);
// get(fname);
while(fname[i]!=".") //INVALID INDIRECTION//AND//TOO FEW PARAMETERS IN CALL TO STRCMP
{
first[i]=fname[i]; //INVALID INDIRECTION//
i++;
}
while(fname[i]!="/0") //INVALID INDIRECTION//
{
ext[i]=fname[i];  //INVALID INDIRECTION//
i++;
}
strcat(command,"dir ");
if(strcmp(first,NULL)!=0)
strcat(command,first);
if(strcmp(ext,NULL)!=0)
{
strcat(command,".");
strcat(command,ext);
}
}
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 19 Jul, 2008 - 07:01 AM
Post #6


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,644



Thanked 51 times

Dream Kudos: 1575

Expert In: (X)HTML, CSS, Batch Scripting, C, C++

My Contributions


Do not use the thanks feature to ask me for help.
User is offlineProfile CardPM

Go to the top of the page

KYA
post 19 Jul, 2008 - 07:05 AM
Post #7


#include <nerd.h>

Group Icon
Joined: 14 Sep, 2007
Posts: 2,933



Thanked 22 times

Dream Kudos: 1150
My Contributions


ph34r.gif
User is online!Profile CardPM

Go to the top of the page

gabehabe
post 19 Jul, 2008 - 07:23 AM
Post #8


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,644



Thanked 51 times

Dream Kudos: 1575

Expert In: (X)HTML, CSS, Batch Scripting, C, C++

My Contributions


IPB Image
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 9/8/08 09:50AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month