如何清除控制台中之前输出的几条cout线?

时间:2014-10-05 03:22:32

标签: c++ cout

当我在控制台中输出3字符串组件的电子邮件对象(发件人的地址,主题,电子邮件)时,如何让用户选择清除那些而不是整个控制台?

    //MAIN MENU OPTION 1 SELECTED:
// print list of all messages to the console
void viewInbox()
{
    vector<Message> inbox{
        Message("jayleno@hotmail.com", "Knife you tonight", "Hey Sam, what kind of suit do you wanna be buried in?!"),
        Message("paypalservices@hotmail.com", "Urgent from paypal.com", "Dear paypal user, someone has hacked your account. Give us your password now so we change it!"),
    };
    cout << "You have " << inbox.size() << " new messages.\n";
    cout << "Index      Subject" << '\n';

    for (int i = 0; i < inbox.size(); ++i)
    {
        std::cout << "Message " << i << ": " << inbox[i].getSubject() << '\n';
    }//end of for loop
    cout << "Please enter number of message you would like to view\n";
    int message_number;
    cin >> message_number;
    cout << "From: " << inbox[message_number].getAddress() << endl;
    cout << "Subject: " << inbox[message_number].getSubject() << endl;
    cout << inbox[message_number].getMessageText() << endl;
    cout << "To close this message and return to your inbox, press 1\n";
    //cin.clear(previous 4 cout lines above only);
}//end of viewInbox()

换句话说,当用户cin为1时,以红色圈出的东西需要消失: what needs to be cleared when user cin's 1

然后,系统会提示用户在收件箱中打开另一封电子邮件。

0 个答案:

没有答案