// Another version of addTwo reading input from a file this time // Copyleft: Sathiamoorthy Manoharan. #include #include int main() { std::ifstream ifs("myints.txt"); // make file stream from "myints.txt" int a, b; // Receive from the input file stream the integer values 'a' and 'b' ifs >> a >> b; // Send to the output stream a string and the integer sum std::cout << "sum: " << (a+b) << "\n"; ifs.close(); // close the input file stream // Suppose we want to write the output to a file "mysum.txt" std::ofstream ofs("mysum.txt"); ofs << "sum: " << (a+b) << "\n"; return 0; }