Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i edit the dirent.h Library i get the intellisense like :"DIR","opendir"
but when i compile this code I have a problem appears
see my screen :
click my screen
Posted
Comments
enhzflep 6-Aug-14 13:04pm    
If that's what your screen looks like, you should skip the pr0n when trying to write code. Posting screenshots to a site that displays ads showing nipples and viagra tablets is probably not the wisest idea.. :laugh:

That said, I see 4 references to dir in your code, yet I don't see it declared anywhere - which, oddly enough, is just the same error that Intellisense reports.

How is dir declared? Or more to the point, are you sure that you have declared it?
Member 10631195 6-Aug-14 13:44pm    
dir declared like this:
DIR *dir;
Member 10631195 6-Aug-14 13:44pm    
*once
Member 10631195 6-Aug-14 13:52pm    
Sorry about the site and the pictures I did not know it was like that the first time I bring up this site
CPallini 6-Aug-14 14:22pm    
You could just post the error message here.

You never declare the symbol dir. How can this message be unclear? Declare the variable or a type member. If you already have the declaration of the variable or member under the same name and still have this error, it means it is done in the scope not visible in the content you are trying to use this object. C++ scope and visibility rules are extremely simple, you can learn them in no time. Please do, otherwise you hardly can go far.

And please, this question requires pure textual information: some code sample + error information. Was it so difficult to provide this information in your question in the form of properly formatted text? After all, you have a clipboard. A screenshot is extremely inconvenient.

—SA
 
Share this answer
 
Comments
Member 10631195 6-Aug-14 14:22pm    
i have Declare the variable . And still have the problem

The problem could be because I added maybe not good for the dirent.h ?
the code:

DIR *dir=NULL;
CString str=getCurrentPath();

//cstring to char*
CT2A ascii(str);

const char* path2=ascii.m_psz;
dir=opendir(path2);

struct dirent *ent;
if (dir != NULL)
{
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL)
{
string name=ent->d_name;
CString name2(name.c_str());
lbTextureFiles->AddString(name2);
}
closedir (dir);
}
Sergey Alexandrovich Kryukov 6-Aug-14 14:38pm    
Yes, in this fragment you did, but it won't show this error. But don't declare it there. It should be in one like:
DIR * dir = opendir(path2);
—SA
Member 10631195 6-Aug-14 14:42pm    
I did what you said and I still have trouble trying to answer the second thanks anyway for the help
Sergey Alexandrovich Kryukov 6-Aug-14 14:44pm    
Sorry, I failed to understand you last comment. What "second"? Does this fragment of code compile now?
—SA
Member 10631195 6-Aug-14 14:44pm    
I just want to get the file paths in some directory
Please note opendir is a Linux function (see opendir man page[^]). Look at this Stack Overflow question for suggestions: "Microsoft Visual Studio: opendir() and readdir(), how?"[^].
 
Share this answer
 
Comments
Member 10631195 6-Aug-14 15:01pm    
Thank context of what I have proposed, I found another article but thank you very much for the reply

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