다음 코드를 봐 주세요.
책에 있는 예제 코드인데요, 실행시에 문제가 발생하네요.
일단 코드 올라갑니다.
[code:1]
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
void printdir(char *dir, int depth)
{
DIR *dp;
struct dirent *entry;
struct stat statbuf;
if((dp = opendir(dir)) == NULL){
fprintf(stderr,"cannot open directory: %s\n");
return ;
}
chdir(dir);
while((entry = readdir(dp))!= NULL){