ok, heres the code;
Code:
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
int main()
{
int r1;
char num1, num2, num3, num4, num5, num6, num7, num8, num9, num10;
char num11, num12, num13, num14, num15, num16, num17, num18, num19, num20;
//declare other variables here
ifstream inFile; //declare the input file
char filename[20];//filename is used to store the name of the input file
cout << "Enter the name of the input file: "<<flush; //enter the name of the input file
cin >> filename; //read the name of the input file
inFile.open(filename); //open the input file
// ************************************************************ //
// Write your code here //
inFile >>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8>>num9>>num10
>>num11>>num12>>num13>>num14>>num15>>num16>>num17>>num18>>num19>>num20;
r1 = static_cast<int>(num1+num2+num3+num4+num5+num6+num7+num8+num9+
num10+ num11+num12+num13+num14+num15+num16+num17+num18+num19+num20);
cout<<r1<<endl;
cout<<num1<<num2<<num3<<num4<<num5<<num6<<num7<<num8<<num9<<num10<<
num11<<num12<<num13<<num14<<num15<<num16<<num17<<num18<<num19<<num20<<endl;
inFile.close(); //close the input file
cout << endl;
cout << "Press CTR-C to Leave..." << endl;
pause();
return 0;
}
The files contain strings such as:
How are you?