Out of three programming languages that I’ve learnt, C++ has the simplest way to handle the I/O (input/output). I’m trying to demostrate how to write a program that reads doubles from a file, performs addition of those numbers, and print the results to stdout (standard output).
C++ has useful ifstream and fstream classes that provide a stream interface to read and write data from/to files. The difference between both classes is, ifstream can only be used for reading, while fstream can be used for both reading and writing. Since we’re only going to read the files, we better use ifstream class.Continue reading