0
입력을받는 프로그램을 빌드하고 특정 것을 입력 한 것을 감지합니다. 행을 입력 한 후 은으로 소문자로 변환해야합니다. 그러나, 나는 방법을 이해할 수 없다. tolower()를 시도했지만 괄호 안에 무엇을 넣을 지 알 수 없습니다. 코드는 다음과 같습니다.어떻게 문자열을 소문자로 만들 수 있습니까? (C++)
#include <string>
#include <sstream>
#include <iostream>
#include "stdafx.h"
using namespace std;
int main()
{
while (1)
{
string dir = "C:/";
string line;
string afterPrint;
string prompt = "| " + dir + " |> ";
cout << prompt;
cin >> line;
stringstream ss(line);
while (ss)
{
string command;
ss >> command;
command = ;// Command, but lowercase
if (command == "cd")
{
string dir;
if (ss >> dir)
{
cout << "changedir: " << dir << "\n";
string prompt = "| " + dir + " |> ";
}
}
else if (command == "c:" || command == "c:\\" || command == "c:/")
{
cout << "Directory: " << dir << "\n";
}
else
{
cout << "error\n";
}
break;
}
}
return 0;
}
도움을 주시면 대단히 감사하겠습니다!