我正在编写一个 c++ 程序来安装我放在几台计算机上的某些程序。我在代码中放置了一个部分,允许用户选择他们想要的安装。我对 C++ 很生疏,所以我无法接受用户输入。我愿意接受有关更好方法的建议,我相信有几个。
int allOrSelect;
std::cout << "Press 1 if you want all software, press 2 if you want to select";
std::cin >> allOrSelect;
if(allOrSelect == 1)
{
std::cout<< "all software installing ..." <<std::endl;
}
if(allOrSelect == 2)
{
std::cout << "Please select from the following list";
std::cout << "software 1";
std::cout << "software 2";
std::cout << "software 3";
std::cout << "software 4";
std::cout << "Type the appropriate numbers separated by space or comma";
//this is where trouble starts
//I've tried a few different ways to take the user input
//i tried using vector array, but never got it working, but i figured there had to
//be a simpler way. also tried variations of cin.whatever
}
如果您需要更多信息,请告诉我,并提前致谢。