#include <sys/types.h>
#include <dirent.h>
long int telldir(DIR *dirp);
#include <sys/types.h>
#include <dirent.h>
void seekdir(DIR *dirp, long int loc);
#include <stdio.h>
#include <dirent.h>
#include <string.h>
int main()
{
DIR *dirp;
struct dirent *dp;
long int loc;
dirp = opendir ("./");
while ((dp = readdir(dirp)) != NULL) {
printf ("%s\n", dp->d_name);
if (strcmp (dp->d_name, "test.txt") == 0)
loc = telldir(dirp);
}
closedir (dirp);
printf ("----------------------new------------------\n");
dirp = opendir ("./");
seekdir (dirp, loc);
while ((dp = readdir(dirp)) != NULL)
printf ("%s\n", dp->d_name);
return (0);
}
./telldir
get_current_dir_name
readdir
mps.c
printf
fdopen.c
readdir.c
test.txt
..
mps
mps_test.c
.
dir_test
mps_test
fileno.c
fileno
printf.c
get_current_dir_name.c
telldir.c
telldir
fdopen
----------------------new------------------
..
mps
mps_test.c
.
dir_test
mps_test
fileno.c
fileno
printf.c
get_current_dir_name.c
telldir.c
telldir
fdopen
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |