星期一, 12月 28, 2009

opendir & readdir

#include
#include
#include
#include

int main(){
char path[]="/sys/bus/mmc/devices/";
DIR * dir;
struct dirent * ptr;
int i;
dir =opendir( path );
while((ptr = readdir(dir))!=NULL) {
if( !strncmp( ptr->d_name,"mmc0", 4) ) printf("d_name: %s\n",ptr->d_name);

}
closedir(dir);
}

沒有留言: