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;
}
ヘルプは高く評価されます。