Just concatenate a filename you get from readdir() to the name of directory you're traversing. Something along the lines of the following:
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#define PATH_MAX 1024
int main(int argc, char **argv) {
DIR *d;
struct dirent *e;
char fullpath[PATH_MAX];
struct stat st;
if(argc > 1) {
if((d = opendir(argv[1])) == NULL) return 1;
} else
return 2;
while ((e = readdir(d)) != NULL) {
snprintf(fullpath, PATH_MAX, "%s/%s", argv[1], e->d_name);
if((stat(fullpath, &st)) == 0)
printf("Did stat(%s) and got block count %u.\n",
fullpath, st.st_blocks);
}
}