Efficient way to save a buffer into a readable file?

I’ve developed a sandbox game in SDL 2 and I’m getting near finishing it. I’m looking for a way to save an image of the buffer (It doesn’t matter if it’s just an image; the way it works is just hold the button down, boom, you've placed something so I don’t need to modify the textures ever again, I’ll just overlap them).

I may be missing some functions recent SDL has added, but I’ve thought of reading every pixel, saving all the information in a huge array, and then exporting that array to a file somehow. I would then tell SDL to render every single pixel of these. I’m not sure how to do that though, so any ideas are welcome.

Look at SDL_RenderReadPixels you can save the current screen to buffer.

Maybe it would be easier with BasicC:

https://pl.wikibooks.org/wiki/BasicC

Soon there will even be a simple compression …

Why do you think that some polish website is useful to other users here?

Therefore, it is easy to use C and SDL and has additional functions.