I want to write the C++ code that can help me to give the drive letter which contains the given folder. I am writing the given code and getting the error while adding the character variable to a string variable at line 11. Can anyone help me out in rectifying the below code.
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <iostream>
#include "Shlwapi.h"
int main()
{
char var;
for (var = 'A'; var <= 'Z'; ++var)
{
char buffer_1[] = var +":\\PerfLogs"; ------->>>> line where i am getting the error
char *lpStr1;
lpStr1 = buffer_1;
int retval;
retval = PathFileExists(lpStr1);
if (retval == 1)
{
std :: cout << "Search for the file path of : " << lpStr1;
system("PAUSE");
}
}
}
std::stringretval = PathFileExists((var + std::string(":\\PerfLogs")).c_str());. Alternatively,char buffer[] = "*:\\PerLogs"; buffer[0] = var; retval = PathFileExists(buffer);std::file_systemhas an abstract notion of root names, but their exact syntax is wholly unspecified by C++. The only thing you know is that they're represented as strings, and there's no way you can portably enumerate these strings.#include <windows.h>