Scared to run this couple lines of coding

If I were to run this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <fstream>

int main() {
	std::fstream file;
	file.open("Note.txt", std::ios::out);

	if(file.is_open() == true) {
		for(;;)
			file<<"0123456789"<<std::endl;
	}
	file.close();

	return 0;
}


Would there be a possibility that this will take over my hard drive space since the for loop is endless?
Last edited on
it probably would, but very slowly. You can stop your program way before it becomes an issue.

EDIT: 50 Mb in 8 seconds. Really slow.
Last edited on
remove the for(; ;) statement and it won't run endless.
Oh ok well I understand the code entirely and I also know how controll it. I was just curious of the consequences.
Remove std::endl at the file writing routine and it will eat space like 10 times faster (450 MB / 8 sec for me)
Lol thanks for the tip. MiiNiPaa
Last edited on
aha! I remember doing something similar to this at uni, on a friends account!

Created a few thousand folders, then moved all his work in the end folders, so he had to click to the end of each on to see if his work was there!
Some people use it in a virus to make someone's computer slower and to give them less space on their HDD.

You can also use:

1
2
3
4
5
6
while(true){

// code here

}



might be a little faster??
Last edited on
Topic archived. No new replies allowed.