Click here to Skip to main content
15,890,377 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The code goes like this:
include<string>

using namespace System::IO;
include<iostream>

using namespace std;

class files { string *fname[25]; public: files() {*fname=NULL; }

};

class directory { private: directory *d; string *dname[25]; files *ff[25]; int numd,numf; public: directory() { numd=0;numf=0; } void search() { string *a[]=Directory::GetDirectories("D:\"); numd=a-&gt;get_length(); *dname[]=*a[]; for(int q=0;q

    for(int i=0;i&lt;numd;i++)
    { //find files
        string *b[]=Directory::GetFiles(d[i]);
            numf=b-&gt;get_length();
        files.*fname[]=*b[];
        for(int c=0;c&lt;numf;c++)
            cout&lt;&lt;files.*fname[c];

}
}

};

int main() { directory r; r.search(); return 0; }


the errors are as follows:
Error 1 error C2440: 'initializing' : cannot convert from 'cli::array ^' to 'std::string *[]' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 19

Error 2 error C2227: left of '-&gt;get_length' must point to class/struct/union/generic type c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 20

Error 3 error C2059: syntax error : ']' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 21

Error 4 error C2665: 'System::IO::Directory::GetFiles' : none of the 3 overloads could convert all the argument types c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 28

Error 5 error C2227: left of '-&gt;get_length' must point to class/struct/union/generic type c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 29

Error 6 error C2143: syntax error : missing ';' before '.*' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 30

Error 7 error C2143: syntax error : missing ';' before '.*' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 30

Error 8 error C2065: 'fname' : undeclared identifier c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 32


Please don't change the logic by adding some kind of boost library stuff or .net stuff. I am using visual c++ 2008. I want to stick to this code. I am looking forward for your suggestions. Please help me as these pointers are becoming a headacke for me. Also please forgive if there are any editing mistakes.

[edit]Inline code converted to code block, Capitalization - OriginalGriff[/edit]
Posted
Updated 12-Mar-11 5:01am
v2

1 solution

Where do I start?

Error 1: "b" is not a pointer. "b" is an array of pointers to strings. To access an individual string, you need to derefence it. Try "b[0]->get_length()" instead. It won't work, beacuse there is a good chance you need to add another loop, but hey! It's your logic.
Error 2: Caused by (1)
Error 3: Same thing, a different way.

I'll stop there, you get the idea.

Go back a stage, and try thinking about what you are doing before you leap into code.
 
Share this answer
 
Comments
WajihaAhmed 14-Mar-11 10:34am    
Thanks alot for pointing the mistakes. I got your point! Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900