Hello,
I have this function
Code:
#include <io.h>
#include <string>
#include <fstream>
int rec_dir_list(string path){
static int count = 0;
struct _finddata_t c_file;
long fh;
string t_path = path;
t_path += "\\*.*";
if((fh=_findfirst(t_path.c_str(),&c_file)) != -1)
while(_findnext(fh, &c_file) == 0)
// ignore '.' and '..'
if(strncmp(c_file.name, ".", 1) != 0
&& strncmp(c_file.name, "..", 2) != 0) {
if((c_file.attrib & _A_SUBDIR) == _A_SUBDIR) {
rec_dir_list(path + "\\" + c_file.name);
cout << "DIR: " << path << "\\" << c_file.name << endl;
count++;
}
}
return count;
}
which is called from main file, function main like this
Code:
string DIR="c:";
cout << "There are " << rec_dir_list(DIR) << " sub directories\n";
and I get errors during compiling:
C:\Users\John\Desktop\aass\bClass.cpp|5|error: 'string' was not declared in this scope|
C:\Users\John\Desktop\aass\bClass.cpp|5|error: expected ',' or ';' before '{' token|
||=== Build finished: 2 errors, 0 warnings ===|
But If I use same function placed in (single) main file it works OK.
What do I do wrong?