Scandir ()

This is a discussion on Scandir () within the C Programming forums, part of the General Programming Boards category; DESCRIPTION The scandir() function scans the directory dir, calling select() on each directory entry. Entries for which select() returns non-zero ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    12

    Scandir ()

    DESCRIPTION
    The scandir() function scans the directory dir, calling
    select() on each directory entry. Entries for which
    select() returns non-zero are stored in strings allocated
    via malloc(), sorted using qsort() with the comparison
    function compar(), and collected in array namelist which
    is allocated via malloc(). If select is NULL, all entries
    are selected.

    The alphasort() function can be used as the comparison
    function for the scandir() function to sort the directory
    entries into alphabetical order. Its parameters are the
    two directory entries, a and b, to compare.

    RETURN VALUE
    The scandir() function returns the number of directory
    entries selected or -1 if an error occurs.

    The alphasort() function returns an integer less than,
    equal to, or greater than zero if the first argument is
    considered to be respecscandirtively less than, equal to, or
    greater than the second.


    How does the alphasort work in scandir?

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    From what I can tell it a pointer to a built in function. The function itself may look something similar to the cmpstringp function shown as an example on the qsort manpage: http://linux.die.net/man/3/qsort

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. scandir help
    By thinice16 in forum C Programming
    Replies: 11
    Last Post: 10-03-2008, 01:28 PM
  2. scandir
    By gurvinder in forum C Programming
    Replies: 3
    Last Post: 08-07-2008, 02:32 PM
  3. scandir
    By gurvinder in forum C Programming
    Replies: 0
    Last Post: 08-07-2008, 12:29 PM
  4. scandir
    By micke in forum C Programming
    Replies: 2
    Last Post: 06-09-2003, 02:04 PM
  5. scandir select function
    By dsl24 in forum C Programming
    Replies: 3
    Last Post: 04-12-2002, 10:58 AM

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