so this is sample of showing what's in directory.
i believe it is with classes...could i remake it, so it would be without classes? because it is abit too hard for me. could you give me a hand redoing it? thank you.
Code:#include <sys/types.h> #include <dirent.h> #include <errno.h> #include <vector> #include <string> #include <iostream> int dirfunct ( std::string const & path , std::vector <std::string> & dirEntryNames ) { DIR * dir = opendir( path.c_str() ); if ( dir != NULL ) { dirent * entry( NULL ); do { entry = readdir( dir ); if ( entry != NULL ) { dirEntryNames.push_back( entry->d_name ); } } while ( entry!= NULL ); if ( closedir( dir ) ) { return -1; } } else { return -1; } return 0; } int main() { std::string path; std::cout << "Path: "; std::cin >> path; std::vector<std::string> entries; if ( !dirfunct(path, entries) ) { std::cout << "Contents of path:\n"; for ( int i=0; i < entries.size(); ++i ) { std::cout << entries[i] << "\n"; } } }



LinkBack URL
About LinkBacks


