/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that reads the specifed postion in a directory. */
#include <stdio.h>
#include <dirent.h>

int main() {
    DIR *dirp;
    struct dirent *direntp;
    long int loc;
    int i;
    
    dirp = opendir( "." );
    while((direntp = readdir( dirp )) != NULL)
      printf( "%s\n", direntp->d_name );

    /* start to read from dir . again */
    dirp = opendir( "." );
    loc  = telldir(dirp); /* get the current location associated with
                             the directory stream */
    seekdir(dirp,loc);  /* move the current location of directory 
                             to next  */
    direntp = readdir(dirp);
    printf( "%s\n", direntp->d_name);
    closedir( dirp );
}
