I have to write a simple beginning program that allows you to input two integers and then the program adds those two numbers and gives you the answer. The problem is my professor wants us to be more advanced and to ignore characters in one line except for integers.
As an example:
65 45
or
78 books
56
or
21.89
87
or
35sk kljfdakjlf
5 jkfdal
This is my program that asks for two integers and gives the result:
int main()
{
int num1, num2;
cout << "Please give me an integer: ";
cin >> num1;
cout << "Please give me another integer: ";
cin >> num2;
cout << endl;
cout << "The sum of " << num1 << " + " << num2 << " = " << num1 + num2 << endl;
system("pause");
return 0;
}
How do I ignore spaces in between integers, letters, periods and the space in between characters so I just get the integers?