文字列 si の代わりに文字列 s ( "C:/Users/John/Desktop/mama/*" ) に格納されているものを書き込む場合、矢印はうまく機能しますが、パスを取得するため、このように使用する必要がありますユーザー。文字列で機能させるにはどうすればよいですか?エラー: エラー 1 エラー C2664: 'FindFirstFileA': パラメーター 1 を 'std::string' から 'LPCSTR' に変換できません
また、このエラーの前に別の同様のエラーが発生し、文字セットをUnicodeからNot setに変更して機能させました。この変更はメイン プロジェクトに問題を引き起こしますか? これはテストです。問題がなければ、ハッシュテーブル プロジェクトに追加します。お時間をいただきありがとうございます:)
#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");
}