Using this solution with dirent.h, I'm trying to iterate on specific files of the current folder (those which have .wav
extension and begin with 3 digits) with the following code :
(Important note: as I use MSVC++ 2010, it seems that I cannot use #include <regex>
, and that I cannot use this as well because no C++11 support)
DIR *dir;
struct dirent *ent;
if ((dir = opendir (".")) != NULL) {
while ((ent = readdir (dir)) != NULL) {
printf ("%s\n", ent->d_name);
//if substr(ent->d_name, 0, 3) ... // what to do here to
// check if those 3 first char are digits?
// int i = susbtr(ent->d_name, 0, 3).strtoi(); // error here! how to parse
// the 3 first char (digits) as int?
// if susbtr(ent->d_name, strlen(ent->d_name)-3) != "wav" // ...
}
closedir (dir);
} else {
perror ("");
return EXIT_FAILURE;
}
How to perform these tests with MSVC++2010 in which C+11 support is not fully present?