Where the arrow is if instead of string s i write what is stored in string s ( "C:/Users/John/Desktop/mama/*" ) it works well but i need to use it like this because i will get the path from the user. How can i make it work with a string? Error : Error 1 error C2664: 'FindFirstFileA' : cannot convert parameter 1 from 'std::string' to 'LPCSTR'
Also before this error oneother similar error appeared and i changed character set from Unicode to Not set to make it work. Is this change going to create trouble to my main project? This one is a test and when it will be ok i will add it to my hashtable project! Thank you for your time :)
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <tchar.h>
#include <stdio.h>
using namespace std;
struct pathname
{
string path;
pathname *next;
};
int main()
{
pathname *head = new pathname;
pathname *temp = head;
WIN32_FIND_DATA fData;
string s = "C:/Users/John/Desktop/mama/*";
void * handle = FindFirstFile( s, &fData ); //<~~~~~~
FindNextFile(handle, &fData);//meta apo auto emfanizei ta onomata
FindNextFile(handle, &fData);
temp->next = 0;
temp->path = fData.cFileName;
while (FindNextFile(handle, &fData) != 0) //swsto listing
{
temp->next = new pathname;
temp = temp->next;
temp->next = 0;
temp->path = fData.cFileName;
}
temp = head;
cout <<"edw arxizei" <<endl;
while(temp != 0)
{
cout << temp->path << endl;
temp = temp->next;
}
system("pause");
}