// ASCIIperLine.cpp // Add Up ASCII values of each character on a line in an ifstream // and output to an ofstream #include #include #include "utility.h" using namespace std; void ASCIIperLine(ifstream &); int main() {ifstream Source; if (OpenForRead(Source)<0) { cout << "Open Failed..Check the Data File Name\n"; exit(1); } ASCIIperLine(Source); Source.close(); } // Perform the Conversion // Precondition: Arguments represent successfully opened file void ASCIIperLine(ifstream &Infile) {char ch; int sum,total=0; while (!Infile.eof()) { sum=0; do { Infile.get(ch); sum+=ch; } while (ch != '\n' && !Infile.eof()); total+=sum; cout << sum << endl; } cout << "Total ASCII: " << total << endl; }