Thread: Making C program read name of files

  1. #1
    Fedryan
    Guest

    Making C program read name of files

    Hi!

    We are writing a C-program, which should search in MIDI-files. We would like it to read the names of the music in a folder, so for example we create a folder including 4 songs named:

    ACDC-TNT
    Bon_Jovi-Living_on_a_Prayer
    Beethoven-Fur_Elise
    Basshunter-Boten_Anna

    It should somehow read the names of the files. Are there any good ways to do this in C :-)?

    /Fedryan

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Since you have to interface with the operating system, the way to do this will be operating-system-specific. On *nix, you're looking at opendir/scandir; on Windows, the FindFirstFile/FindNextFile functions.

  3. #3
    Fedryan
    Guest
    Oh, yes, this is for Windows I can not find "FindFirstFile" function in the C index?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336

  5. #5
    Fedryan
    Guest
    The only links I can find is for c++ not c >.<

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Fedryan View Post
    The only links I can find is for c++ not c >.<
    Microsoft does not currently acknowledge the existence of C; however, basically all of their (non .NET) API is in C. FindFirstFile is a C function.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Fedryan View Post
    The only links I can find is for c++ not c >.<
    FindFirstFile(), like all functions in the win32 API, uses POD types (or opaque types). The techniques to use it in C and C++ are therefore virtually identical. The only differences come in with other code that uses C++-specific features, with C++ class types needing to be mapped back to POD types.


    Quote Originally Posted by tabstop View Post
    FindFirstFile is a C function.
    No it's not. It is a win32 API function that can be called from C code (assuming a compiler/library for windows).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making a program delete itself using bat files
    By Danne in forum C++ Programming
    Replies: 8
    Last Post: 02-20-2011, 03:54 AM
  2. Making a file read only
    By linuxlover in forum C Programming
    Replies: 10
    Last Post: 11-25-2010, 02:36 PM
  3. Making a File to be read
    By dapernia in forum C Programming
    Replies: 9
    Last Post: 09-04-2003, 09:50 PM
  4. my program wont read my text files in??
    By Neildadon in forum C++ Programming
    Replies: 2
    Last Post: 12-15-2002, 10:08 AM
  5. Creating files then Hiding them or making them Read-Only...how?
    By Kyoto Oshiro in forum C++ Programming
    Replies: 7
    Last Post: 03-09-2002, 07:30 PM