Save SDL2 audio to WAV

I’ve searched this forum and and the internet and can not find a way to take audio data recorded through SDL2 and write it to a WAV file. Is there an example somewhere or some API I can use?

I don’t need WAV specifically. Just looking to save recorded data to an audio file that can be played with an external application.

The same question was asked quite recently. You should find what you need there.