Thread: file handling codes

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    1

    file handling codes

    Please send me codes for searching for files in a particular directory which start with a letter say"a".
    and also send me code for deleting the contents of the file such found.

    thanks nd regards,
    ram

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    A C guide:
    http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

    A list of POSIX functions, which might be useful, if they are available to you.
    http://cplus.kompf.de/posixlist_print.html

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Logging a directory in Windows.

    To delete a file use the DeleteFile() API function.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Banned
    Join Date
    May 2003
    Posts
    124
    >DeleteFile() API function
    What's that?

    To delete a file use function:

    int remove(const char *filename);

    from stdio.h

  5. #5
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    DeleteFile is the Windows API function for deleting a file. In Windows, remove() calls that function.

  6. #6
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    then why not be more portable and use remove?

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> then why not be more portable and use remove

    I did say in my message "if you are using Windows".

    If people are working on a particular platform, with no plan to put it on any other, why worry about portability? One could just as well say if remove() is going to call DeleteFile() anyway, why take the overhead of pushing the stack, jumping, then cleaning the stack again?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM