c program to print list of files in a directory

This is a discussion on c program to print list of files in a directory within the Linux Programming forums, part of the Platform Specific Boards category; Hi friends, i want a program to print all the files in a directory recursively without using ls command and ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    1

    c program to print list of files in a directory

    Hi friends,

    i want a program to print all the files in a directory recursively without using ls command and system command. Any body have idea let me know?

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Well, to start with, look up readdir(3) in your manpages, as well as opendir.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Or even the FAQ
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    5
    Hi,
    You can do it using FTW (file tree walk), do man ftw to get more details. using the api ftw, u can give the directory name and a pointer to a function, in the function use must print the file name. It is very easy. hope this will help you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. List all system and program files
    By tnbui in forum Windows Programming
    Replies: 7
    Last Post: 07-10-2009, 03:43 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 11:10 AM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 09:55 PM
  4. Adding directory/file names to a linked list
    By thoseion in forum C Programming
    Replies: 13
    Last Post: 12-08-2006, 01:13 PM
  5. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 09:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21