pleaaaaaaaaaaase help me !!
Any body help me pleaaaaase , I want
C / C++ code that can be listing ( list files) file by another command , I mean not by command ( LS ) , and the program take the path from user , I hope that any body help me as possible ... Thanks Alot >>> |
Your apt to get more help if you try to do it on your own and post your code. I don't think you're going to find anyone to do the whole thing for you, but I'm sure plenty of people would be glad to help.
|
Sounds like some programming homework to me.
A |
/* sample program to illustrate the opendir(), readdir() and stat()
system calls it lists all files in the given directory, and adds an asterisk to each one which is a subdirectory */ #include <sys/types.h> #include <sys/stat.h> #include <sys/dir.h> #define MAX_CHARS 200 int CharsRead,Tmp; /* number of characters read from a directory entry */ struct direct *DirEntryPtr; /* pointer to a directory entry */ DIR *DirPtr; /* pointer to the directory */ struct stat Stat; char Path[MAX_CHARS]; main(argc,argv) int argc; char **argv; { DirPtr = opendir(argv[1]); while (1) { DirEntryPtr = readdir(DirPtr); if (DirEntryPtr == 0) break; /* reached end of directory entries */ /* process file (other than . and ..) */ if (strcmp(DirEntryPtr->d_name,".") != 0 && strcmp(DirEntryPtr->d_name,"..") != 0) { /* print file name */ printf("%s",DirEntryPtr->d_name); /* build full path name of the file, for stat() */ Path[0] = 0; strcat(Path,argv[1]); strcat(Path,"/"); strcat(Path,DirEntryPtr->d_name); Tmp = stat(Path,&Stat); /* Stat now contains lots of info about the file, e.g. its size, though we are not interested in most of that info here */ if (S_ISDIR(Stat.st_mode)) printf("*"); printf("\n"); } } } This is my trying ,,, but its so bad because there are some errors ,, If any body help me I willl thank ful for him ,,, |
Here's a fixed-up version of your code:
Code:
#include <stdio.h> |
itsme86 , Thanks >>
|
All times are GMT -5. The time now is 09:52 AM. |