【发布时间】:2013-01-26 17:17:18
【问题描述】:
好吧,有些人可能还记得我之前的样子,我对编程还很陌生,所以我可能看起来比不上许多其他人。但是目前,我非常卡住。
int main(int argc, char* argv[]) {
string temp,input,output;//store input from file, and get which file//
ofstream out("output.txt");
if(argc == 3)
{
if(ifstream(argv[2]))
{
input = argv[2];
ifstream in(input);
while(in.good())
{
in >> temp;
ReverseWord(temp);
cout << temp << endl;
out << temp << endl;
}
out.close();
in.close();
}
}
}
此处的代码旨在通过键入“revstr
【问题讨论】:
-
在 Windows 上?
system("pause");... -
<在 shell 中是特殊的(包括cmd.exe):它将输入从文件重定向到您的stdin(或std::cin),并且程序看不到 既不是<也不是文件名。 -
或者更好,
cin.ignore()和cin.get()。 -
@chris 我会将这些放在代码中的什么位置?
-
为什么
argc会是 3?论据是什么?