[英]C++ program ends before user input
For my C++ homework, I am supposed to use one function to read to integers, use another one to add them and the last one to print out the sum.对于我的 C++ 作业,我应该使用一个函数读取整数,使用另一个函数将它们相加,最后一个函数打印出总和。 I am doing the first function and my program ends before allowing for input
我正在做第一个功能,我的程序在允许输入之前结束
I have tried using cin: clear and nothing changed I have tried removing the return and got an error.我试过使用 cin: clear 并且没有任何改变 我试过删除返回并出现错误。
#include <iostream>
using namespace std;
int A;
int B;
int X;
//void Input();
int main()
{
int Input(int A, int B);
return 0;
}
int Input(int A, int B)
{
cin >> A;
cin >> B;
return 0;
}
I expected it to blink telling the user to enter input because I can not use input messages but it runs then ends without letting me enter input我希望它闪烁告诉用户输入,因为我不能使用输入消息,但它运行然后结束而不让我输入输入
int Input(int A, int B);
This is a declaration.这是一个声明。 It is not a call.
这不是电话。
Furthermore there does not appear to be any reason for Input
to take any int
parameters.此外,
Input
似乎没有任何理由采用任何int
参数。
Turn to the page in your C++ book about using functions.转到 C++ 书中关于使用函数的页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.