C++ || Snippet – How To Create A File Of Any Size

Print Friendly, PDF & Email

The following is sample code which demonstrates how to create a file of any size using the fseek and fwrite function calls.

The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

The following is sample output:

./createfileN createfile.txt 12

[FILE "createfile.txt" IS CREATED AND IS 12 BYTES IN SIZE]

Was this article helpful?
👍 YesNo

Leave a Reply