![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Command to list directory names only | stevefox | UNIX for Dummies Questions & Answers | 6 | 11-29-2007 05:06 PM |
| how to list a directory & file | gagasan_makmur | UNIX for Dummies Questions & Answers | 2 | 09-26-2006 09:40 PM |
| Directory list inside a directory | little_jhon | UNIX for Dummies Questions & Answers | 6 | 01-14-2006 10:05 AM |
| list of files in one Directory | venkyA | UNIX for Dummies Questions & Answers | 3 | 06-24-2005 01:49 PM |
| can we list other than c files in a directory with only 'ls' command? | venkat | UNIX for Dummies Questions & Answers | 3 | 03-12-2004 06:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
list directory without use ls command?
Hi
i need C code to list direcoty without using ls command and it sould take the path of the directory from the user? "please help me it is so important" |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
#include <stdio.h>
#include <string.h> // for access #include <fcntl.h> #include <dirent.h> // for struct dirent #include <sys/stat.h> //for struct stat and the functions related to it int main(int argc, char **argv) { struct dirent *dp; DIR *dirp; // structure for the directory if(argc != 2) { fprintf(stderr, "Usage: ./a.out dirName"); exit(1); } dirp=opendir(argv[1]); while((dp=readdir(dirp))!= NULL) printf("%s\n", dp->d_name); } |
|
#3
|
|||
|
|||
|
thanx for your help but i need that with out using C function also
like "printf(),opendir()", it must use system calls only like "read(),write" |
|
#4
|
||||
|
||||
|
The artificial restriction tells us that this is a homework assignment. If you read the unix.com rules:
Simple rules of the UNIX.COM forums: ... you'll see that homework assignments do not belong here, so I'll close the thread. Tell your teacher what you're having problems with and I'm sure he'll help you out. |
||||
| Google The UNIX and Linux Forums |