Results 1 to 3 of 3

Thread: [C] List files in directory & macro question

  1. #1
    Join Date
    Sep 2007
    Beans
    471
    Distro
    Ubuntu 11.04 Natty Narwhal

    [C] List files in directory & macro question

    Is there a way in a linux environment to list all files in a specific directory? I wonder if it's possible in C and not C++ or C# since I studying for a course.

    Macro question:
    Could someone explain what this macro do?
    PHP Code:
    #define DATA_REG (*(unsigned char *) 0x200 ) 

  2. #2
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,264
    Distro
    Kubuntu

    Re: [C] List files in directory & macro question

    You can use the combination of opendir() and then readdir() to get the contents of a directory. Don't forget to use closedir() when you are done.

    As for your other question, the inner cast is treating the 0x200 as an address, and then the outer '*' is dereferencing the address so that the value at the address can be read (and if permitted, written to). If for example, the address represents a 16-bit (2-word) register, you could use the macro as such:
    Code:
    unsigned short value = DATA_REG;

  3. #3
    Join Date
    Sep 2007
    Beans
    471
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: [C] List files in directory & macro question

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •