【发布时间】:2015-08-16 04:58:16
【问题描述】:
我想知道我是否使用正确的形式将我的命令放在一行中,然后通过ifs 获取每个命令所需的信息。这是我的代码的一部分;实际上,我的main 函数的第一部分:
string line;
stringstream ss;
while (!cin.eof())
{
getline(cin, line);
//i dont know if next line should be used
ss << line;
if (line.size() == 0)
continue;
ss >> command;
if (command == "put")
{
string your_file_ad, destin_ad;
ss >> your_file_ad >> destin_ad;
//baraye history ezafe shod
give_file(your_file_ad, p_online)->index_plus(command);
【问题讨论】:
-
我想你想根据命令的值做一些处理,并将每个命令的详细信息写在字符串流上,对吗?
-
是的,基于什么命令我会从用户那里得到不同的信息...
-
谁教你写
while (!cin.eof())?那是不正确。
标签: c++ getline stringstream