Hopefully this should be an easy problem I have looked all over my code and I cannot find where the problem lies. The program reads to large ints from a text file adds them and then outputs the result. Ive included the code below.
and here is the file it is reading fromCode:int main() { bigint a, b, c; std::ofstream outfile("results.txt"); std::ifstream infile("data1-1.txt"); if(infile.is_open()) { std::cout << "file open \n"; while (infile >> a) { infile >> b; std::cout << a; std::cout << b; std::cout << "+__________________________________________\n"; c = a + b; std::cout << c; } } else std::cout << "Unable to open file\n"; outfile.close(); infile.close(); return 0; }
This is a simple ADT exercise the input operator will read until the semicolon. The program works fine without reading from the file in a loop, but that is a requirement for this assignment.Code:1123215504550654654648632143546546440808844113546654696870324465406587305476857035744424554321649523187432184732416847321; 3216654832155555151321; 654448798765213211154654521035421556543324432153214463; 65444068465406540065400666554448779873544321115674877635413246543214;
Any help would be greatly appreciated




Reply With Quote