What is the fastest and most efficient way to prepend bytes at the beginning of a file? Basically, I want to open a file and then add a number of bytes to it. I thought of using a loop, but given that all of the bytes to prepend are the same, I don’t think it would be necessary.
Share
This is about the most succinct way I could personally think of, but doesn’t avoid loops like you wanted:
It could also use some error handling, but you get the idea.