I am currently learning C++. Today I took a break and thought of what I had learnt so far. The last days I have learnt to create files and to send arguments to the main() function through the CMD.
I just wonder since I do not want to try this:
If you make a program that first creates a .txt file and then fill it with tons of data. Then you make an infinite while loop that copies the file continiously. Will this finally result that the harddrive in a short time will become full and crash if your PC is fast enough? I wonder this, since I became curious about it and can not stop thinking of it, and I do not want to try it.
The hard drive will fill up, but it's not likely to lead to a crash (most modern OS wouldn't). And it may take quite a while to fill the hard-drive, especially if the file you are copying is quite small.
All ofstream operations fail in the case that the disk is full, so you wont be able to crash the computer.
Go ahead and try it, this program uses up a teraByte. It will take a while. Also note that the file opened are all opened to a sub-folder named "test". You need to make this folder yourself before running the program. The purpose of the dub-folder is that it is much faster to delete a folder than have the computer try to select 10000 files.