alla fine ho fatto così, e mi sembra funzionare:

codice:
#include <iostream>
#include <ftw.h>
#include <vector>
#include <string>

using namespace std;
vector<string> v;

int callback(const char *path, const struct stat *st, int flags) {
    v.push_back(path);
    return 0;
}

int main(int argc, char** argv) {
    int f = ftw("/etc", callback, 1);
    vector<string>::iterator it;
    for (it = v.begin(); it < v.end(); ++it) {
        cout << *it << endl;
    }
    return 0;
}