{
WIN32_FIND_DATA file;
HANDLE search_handle=FindFirstFile(L"C:\\*",&file); //it says the L is incompatible
if (search_handle)
{
do
{
std::wcout << file.cFileName << std::endl;
}while(FindNextFile(search_handle,&file));
CloseHandle(search_handle);
}
}
You are attempting to pass an argument of type wchar_t[] to a function that requires an argument of type constchar*. Removing the 'L' that appears beside the first argument being passed to the FindFirstFile() function will fix this error.
#include <iostream>
usingnamespace std;
#include <cwchar>
usingnamespace std;
#include <string>
usingnamespace std;
#include <Windows.h>
usingnamespace std;
char response;
string a;
int main()
{
cout << "Would you like to play a game? Y/N?";
cin >> response;
{
if (response == 'y');
cout << "What game would you like to play? Please type in exactly what the game is called including spaces, dashes, or capitalization.";
cin >> "a";
{
WIN32_FIND_DATA file;
HANDLE search_handle=FindFirstFile("C:\\*",&file);
if (search_handle)
{
do
{
std::wcout << file.cFileName << std::endl;
}while(FindNextFile(search_handle,&file));
CloseHandle(search_handle);
}
}
if (response == 'n')
cout << "Goodbye!";
//countdown loop
for (int n=3; n>0; n--) {
cout << n << ", ";
}
cout << "CIAO!\n";
return 0;
}
When I try to debug this program it works until I type in the program I want it to search for. Then the console gives a list of computer files and i cant type anything in. Also, a thing pops up saying would you like to break, cancel, or continue. Stumped to the maximization.
When I try to debug this program it works until I type in the program I want it to search for. Then the console gives a list of computer files and i cant type anything in. Also, a thing pops up saying would you like to break, cancel, or continue. Stumped to the maximization.
I don't know why you have placed curl brackets throughout your source code. Are you using them to limit the lifetime of your variables? I've removed them from the source code below.
You are attempting to call std::basic_istream::operator>>() with an erroneous argument. The string literal "a" is an lvalue, and it cannot be assigned a new value. You must provide an rvalue that the member function is able to modify. Perhaps you have mistaken the std::cout object with std::cin object?
#include <iostream>
#include <cwchar>
#include <string>
#include <Windows.h>
usingnamespace std;
char response;
string a;
int main()
{
cout << "Would you like to play a game? Y/N?";
cin >> response;
if (response == 'y');
cout << "What game would you like to play? Please type in exactly
what the game is called including spaces, dashes, or capitalization.";
cout << "a";
WIN32_FIND_DATA file;
HANDLE search_handle=FindFirstFile("C:\\*",&file);
if (search_handle)
{
do
{
std::wcout << file.cFileName << std::endl;
}while(FindNextFile(search_handle,&file));
CloseHandle(search_handle);
}
if (response == 'n')
cout << "Goodbye!";
//countdown loop
for (int n=3; n>0; n--) {
cout << n << ", ";
}
cout << "CIAO!\n";
return 0;
}
There are no red lines under anything, so it seems like there wouldn't be any errors. But the break, continue, or cancel message is still the same. Even if I type in "N" instead of "Y". I think the issue is with the function. Thanks for helping me so far.