So My input document has the following data
56 38
A
7 8
My program:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inData;
ofstream outData;
int num1, num2, num3, num4;
char ch1;
inData.open("c:\\inDatat.txt");
outData.open("c:\\outData.txt");
inData >> num1 >> num2;
outData << "Sum of " << num1 << " and " << num2 << " = " << num1 + num2 << endl;
inData >> ch1;
outData << "The character that comes after " << ch1 << " in the ASCII set is B." << endl;
inData >> num3 >> num4;
outData << "The product of " << num3 << " and " << num4 << " = " << num3 * num4 << endl;
inData.close();
outData.close();
return 0;
}
Output on new document should look like this:
Sum of 56 and 38 = 94
The character that comes after A in the ASCII set is B.
The product of 7 and 8 = 56
My output:
Sum of-858993460and-858993460=-1717986920
The character that comes afterÌin the ASCII set is B.
The product of-858993460and-858993460=687194768
Help!