Visual Studio 2015를 사용하여 특정 위치로 특정 파일을 sim-link하는 Windows 10에서 프로그램을 만들려고합니다. 나는 텍스트 파일을 파일의 위치와 함께 사용하려고하고 sim-link 목적지를 사용하려고한다.C++에서 파일 문자열을 명령으로 사용하는 방법
FileLocation : "Z : \ 폴더 \ file.txt를"
FileMkdirLocation : "Z : \ Folder2와 \
이
은properties.txt
파일에있을 것 파일 데이터의 예입니다 file.txt를 "
나는 properties.txt
에있는 데이터를 변경하여 system(mkdir "sim-link_file_location" "file_location")
같은 것을 사용하고 싶습니다. 프로그램을 다시 컴파일하고 각 파일에 대해 각 명령을 하나씩 작성하지 않고 둘 이상의 파일을 추가 할 수 있기를 원합니다.
문제는 명령에서 파일의 데이터를 사용하는 방법을 모르겠다는 것입니다.
편집 : 방법을 찾아 낼 수 있었지만 프로그램을 컴파일 할 때 오류가 발생했습니다. 이 코드를 사용합니다 :
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdlib.h>
using namespace std;
//initialization of Properties File used
ifstream PropertiesFile ("PropertiesFile.txt");
int main()
{
//initialization of variables used
int input_option;
char FileLocation[256], Command[]="mklink ";
// string FileLocation, Command;
PropertiesFile >> FileLocation;
/* switch (input_option)
{
case "add all mods":
}
*/
cout << "FileLocation: " << FileLocation;
cout << endl;
strcat(Command, FileLocation);
Command[strlen(FileLocation)] = '\0';
cout << Command;
cout << endl;
//system(command);
system("pause");
return 0;
}
나는 모든 변수를 아직 사용하지 않았다는 것을 알고 있습니다. 는 "strcat와는"더 이상 사용되지 않으며 대신 "strcat_s"를 사용하고, 나는 그와 함께 교체 할 때, 나는
"디버그 어설 션 실패 - 식 : (L은"얻을 것을 알려줍니다 버퍼가 너무 작습니다 "&을 & 0) "
다시 귀하의 질문은 무엇입니까? –
초 전에 편집했습니다. 나는 "sim-link_file_location"대신에 properties.txt 파일에 쓰여진 데이터를 사용하는 법을 모릅니다. – TermoZour
'sim-link'가 의미하는 것은 무엇입니까 - _symlink_가 아닌 것을 설명해주십시오. – greybeard