VB icon

lcfind

Email
Submitted on: 1/1/2015 8:12:00 AM
By: Luke (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: C
Views: 791
 
     This program allows you to find a file or a directory in a specified drive (e.g. your hard disk, a floppy, your cd-rom...). It search for it in all the directories you have in that drive. Click Luke to go to my Web Page: other source code available...
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: lcfind
// Description:This program allows you to find a file or a directory in a specified drive (e.g. your hard disk, a floppy, your cd-rom...). It search for it in all the directories you have in that drive. Click Luke to go to my Web Page: other source code available...
// By: Luke (from psc cd)
//
// Inputs:You have to input the drive (i.e. 'c' or 'a' or 'd' or whatever else) and the name (or part of it) of the file or directory you're searching for.
//
// Returns:This program return the path of all the files (or directories) found in that drive.
//**************************************

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main(int argc, char *argv[])
{
 char *instruction;
 if (argc != 3)
 {
 printf("\nUsage is: lcfind drive name\n\n");
 printf(" drive: it is the drive in which you want\n");
 printf("to search for your file or directory.\n");
 printf(" name : it is the name of the file (or part of\n");
 printf("the name) or of the directory that you\n");
 printf("are searching for.\n\n");
 printf("Example: lcfind c lcfind\n");
 return -1;
 }
 instruction = calloc(101, sizeof(char));
 strcat(instruction, "dir ");
 strcat(instruction, argv[1]);
 strcat(instruction, ":\\");
 strcat(instruction, "*");
 strcat(instruction, argv[2]);
 strcat(instruction, "* /s /l /b | more");
 system(instruction);
 return 0;
}


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.