简体   繁体   English

程序显示以退出代码 0 结束;

[英]Program displays ended with exit code 0;

I'm trying to complete this program for class assignment.我正在尝试完成此课程以进行课堂作业。 Pretty much the program displays all the requirements.该程序几乎显示了所有要求。 However, I'm getting a Program ended with exit code:0 added to the output.但是,我得到了一个以退出代码结束的程序:0 添加到输出中。 I checked the code, but I didn't find the error.我检查了代码,但没有发现错误。 Can someone tells me how can I remove this message?有人可以告诉我如何删除此消息吗? Thanks for your help.谢谢你的帮助。

#include <iostream>
#include <string>

using namespace std;

int main()

{
    string fname, middle, last;
    cout << "Enter a name in the format First Middle Last:" <<endl;
    cin >> fname >> middle >> last;
    cout << fname  << endl;
    cout << middle << endl;
    cout << last <<endl;

    string fname2 = fname.substr (0,1);
    cout <<fname2 ;
    string middle2 = middle.substr (0,1);
    cout <<middle2;
    string last2= last.substr (0,1);
    cout <<last2 <<endl;
    string middle3 = middle.substr (0,3);
    cout << middle3 <<endl;
    string fullname = fname + " " + middle + "" + last + " ";
    string fullname2 = fullname.substr (7,1);
    cout << fullname2 <<endl;
    string fullname4 = fullname;
    cout << fullname.length() <<endl;

}

This is the output:这是输出:

Enter a name in the format First Middle Last:
Program ended with exit code: 0
Robert anthony Plant
Robert
anthony
Plant
RaP
ant
a
20

Exit code 0 means that the program completed successfully.退出代码 0 表示程序成功完成。 If everything that happened was exactly what you wanted (besides the exit code message), then you're fine.如果发生的一切都正是您想要的(除了退出代码消息),那么您没问题。 All correct programs will end with an exit code 0, if there is another error or exit code then that is where there might be a programming problem.所有正确的程序都将以退出代码 0 结束,如果还有另一个错误或退出代码,那么这就是可能存在编程问题的地方。 It could also have something to do with what platform, IDE, or compiler you are using to run your code.它还可能与您用来运行代码的平台、IDE 或编译器有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM