0

I used this code to create a filestream ,and I tried to output something by this filestream.

Here's my cpp code : (MinGW 9.2.1,Windows 10)

ofstream outfile;
outfile.open("C:\\nul");
for(unsigned long long i=1llu;i<=18446744073709551615ull;++i)
    outfile<<i<<endl;

It ran for a few seconds and I use "Ctrl+C" to kill the progress, but it seem to be the available capacity of my C disk is smaller at runtime. My description may not be accurate enough because of my poor English :(

Let me put it another way: I noticed that the remaining space of my C disk is about 0.2Gb less than before.

Is it output to my C disk?If so,where is it?

I am searching for a long time on Net.Please help give some ideas how to achieve this. Thanks in advance !


Upd:

There is my files on C disk.

I'm really sure that the remaining space of my C disk is much less than before.

Suansuan
  • 1
  • 1
  • @user7860670 ,I want to know where is it than I want to delete it. – Suansuan Nov 30 '20 at 09:29
  • `nul` is one of the [reserved names in Windows](https://stackoverflow.com/questions/122400/what-are-reserved-filenames-for-various-platforms), you cannot really use it. – Yksisarvinen Nov 30 '20 at 09:30
  • @Yksisarvinen ,so the data is not actually written to my disk,right? – Suansuan Nov 30 '20 at 09:33
  • I'm not sure honestly. You should first check if `outfile.is_open()` returns `true` and then if `outfile< – Yksisarvinen Nov 30 '20 at 09:41
  • Does not output to the console prove that it was opened it successfully? @Yksisarvinen – Suansuan Nov 30 '20 at 10:10
  • I tried it just now,it returned true,but it seems that it doesn't work as expected. @Yksisarvinen – Suansuan Nov 30 '20 at 10:15
  • I have sloved this problem,even idk where the files are,but it becomes normal after restarting.Thx for your idea all the same ! @Yksisarvinen – Suansuan Nov 30 '20 at 11:16
  • This doesn't address the question, but get in the habit of initializing objects with meaningful values rather than default-initializing them and then overwriting the default values. In this case, that means changing `ofstream outfile; outfile.open("C:\\nul");` to `ofstream outfile("C:\\nul");`. – Pete Becker Nov 30 '20 at 15:03
  • I get it , thanks for your suggestion. @PeteBecker – Suansuan Dec 01 '20 at 02:46

1 Answers1

0

Oh,maybe it's really on my Disk,I think.

But after restarting my PC,these spaces have been released,the remaining space of my disk is back to before.

Suansuan
  • 1
  • 1