If I change the main program to this:
Everything works fine and I dont get a segmentation fault.Code:int main() { bigint a, b, c; std::string file_name = "data1-1.txt"; std::ofstream outfile("results.txt"); std::ifstream infile("data1-1.txt"); if(infile.is_open()) { infile >> a >> b; std::cout << a; std::cout << b; std::cout << "+__________________________________________\n"; c = a + b; std::cout << c; infile >> a >> b; std::cout << a; std::cout << b; std::cout << "+__________________________________________\n"; c = a + b; std::cout << c; } else std::cout << "Unable to open file: " << file_name << '\n'; outfile.close(); infile.close(); return 0; }




Reply With Quote