This is a basic understanding concepts related question.
Working using: Embarcadero C++ Builder
What is the difference between:
opendir("C:\\XYZ")
and
String file = "C:\\XYZ";
opendir(file);
Aren’t both strings?
The first one works but the sexond gives me error:
E2034 Cannot convert Unicode String to ‘ const char*’
In a case where I take input from the user I can only pass a string. How do i pass the whole path?
first one is a
const char*, second one is a std::string. Theopendirfunction accepts onlyconst char*in your case and thus cannot convertstd::stringtoconst char*on its own. you can get the function to work byopendir(file.c_str());.