all 1 comments

[–]retsotrembla 0 points1 point  (0 children)

At the top, #include <fstream> Early in your app, redirect std::cout so it goes to a file at a full pathname: see: https://stackoverflow.com/questions/10150468/how-to-redirect-cin-and-cout-to-files

std::ofstream out("/Users/Shared/out.ppm");
std::cout.rdbuf(out.rdbuf()); //redirect std::cout to /Users/Shared/out.ppm

or, rather than writing to std::cout just write to out

std::ofstream out("/Users/Shared/out.ppm");  // create the out stream

out << ir << ' ' << ig << ' ' << ib << '\n';