I'm trying to make a program in C, that you enter two numbers into (a and b), it then shows "a+b=n" and returns 0, BUT if the user inputs invalid characters, the program shouldnt write a+b=n and should return 1.
#include <iostream>
int main(){
int a, b;
if (std::cin >> a >> b)
std::cout << a + b << std::endl;
else{
std::cerr << "Input Wrong.\n";
return 1;
}
return 0;
}