Thread: need help about directory

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    need help about directory

    hi all,
    i'm kinda new in c. i need to to write a program where the user will give the name of a directrory n where there will be some text files. the user will also give a string. i have to find that string in those files ( i mean, it the whole directory). i've alreadt finished the searching part for a single file. bt i dont know how to get the files form a directory n enter all of them. somebody plz help me.

    thanx in advance.

    ocean

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Look at the opendir(), readdir(), and closedir() functions.
    If you understand what you're doing, you're not learning anything.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    thanx for the tutorial....... bt it still hard for me to understand.........

    i still cant figure out how can i enter each files from the directory.........

  5. #5
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Quote Originally Posted by itsme86
    Look at the opendir(), readdir(), and closedir() functions.
    Try `man opendir`.

  6. #6
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    Quote Originally Posted by ocean
    i still cant figure out how can i enter each files from the directory.........
    Append the filename to the directory path and fopen() it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  3. Replies: 6
    Last Post: 07-30-2003, 03:08 AM
  4. Directory reading trouble
    By samGwilliam in forum Linux Programming
    Replies: 0
    Last Post: 03-10-2002, 09:43 AM
  5. The Site Directory
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-22-2002, 08:19 PM