-3
私はtxtファイルを作成してデータを置くスクリプトを作っていますが、system();関数、私は奇妙なエラーが発生します。ここにコードがあります。システムエラーC++
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main()
{
string textFileName = "SavedPasswords.txt";
string currentPassword = "Pas123!()";
string currentName = "Home";
string seperator = "====================";
ofstream textFile(textFileName.c_str());
textFile << "N: " << currentName << endl << "P: " << currentPassword << endl << endl << seperator << endl;
string directory;
size_t path = textFileName.rfind("\\");
if(string::npos != path)
{
directory = textFileName.substr(0, path);
}
string systemCommands[3] = {"cd\\",
"cd " + directory,
"start " + textFileName};
system(systemCommands[0]);
system(systemCommands[1]);
system(systemCommands[2]);
}
C:\ Users \ユーザーデスクトップ\ユーザー\ SavePasswords main.cppに\ | 29 |エラー:引数は 'のconstのchar *' に '{のstd ::のbasic_string別名}のstd :: string' を変換することはできません " 1 'から' int system(const char *) 'に変更します。
次の2行で同じエラーが発生します。
システム(systemCommands [0] .c_str())を試したことがありますか。 ? – JGroven
は、「」から「」 –
を選択すると、エラー文字列がグーグルグーグルで返されます –