C++ Make a file of a specific size

前端 未结 3 1632
刺人心
刺人心 2021-01-02 09:03

Here is my current problem: I am trying to create a file of x MB in C++. The user will enter in the file name then enter in a number between 5 and 10 for the size of the fil

3条回答
  •  渐次进展
    2021-01-02 09:21

    To make a 2MB file you have to seek to 2*1024*1024 and write 0 bytes. fput()ting empty string will do no good no matter how many time. And the string is empty, because strings a 0-terminated.

提交回复
热议问题