나는 명령 행 프로그램을 만들고 있는데 문장의 다른 부분을 얻는 방법을 궁금해했다. 따라서 누군가가 cd Windows/Cursors
을 입력했다면 if 문으로)는 cd
을 입력 한 다음 (동일한 if 문에서) 나머지 문장을 선택하고이를 디렉토리로 설정합니다. 내 코드는문장에서 문장의 일부를 선택하는 방법 (C++)
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int main()
{
while (1)
{
string directory = "C:/";
string promptInput;
string afterPrint;
string prompt = "| " + directory + " |> ";
cout << prompt;
cin >> promptInput;
if (promptInput == "")
{
}
else if (promptInput == "h:/")
{
directory = "H:/";
}
if (promptInput != "") {
cout << " " << afterPrint << "\n";
}
}
return 0;
}
아직 시도하지 않았으므로 제안을드립니다.
도움을 주시면 대단히 감사하겠습니다.
-갈렙 심
: 예를 들어, 비주얼 스튜디오, 그리고'#INCLUDE "에 stdafx.h"를 사용하는 경우 '이 제안, 파일의 첫 번째 일에'#INCLUDE "에 stdafx.h"를'했습니다. 그 위에있는 모든 것은 무시됩니다. 자세한 내용은 https://stackoverflow.com/questions/2976035/purpose-of-stdafx-h를 참조하십시오. 왜 사람들은이 smurf를 참아 : https://stackoverflow.com/questions/4726155/whats-the-use-for-stdafx-h-in-visual-studio – user4581301