Windows Equivalent
Nov 29, 2010 at 11:37pm UTC
What's the windows equivilent to /dev/null on unix based systems?
Trying to move a program I originally programmed on FreeBSD to Windows and I gladly used /dev/null.
Thanks Chewy
Nov 30, 2010 at 5:39pm UTC
I think it's NUL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ofstream file("nul" );
if (!file.is_open())
cerr<<"File doesn't exist" ;
else cout <<"OK" <<endl; // nul always exists
file <<"WRITING TO NUL" ;
file.close();
return 0;
}
When I ran this code, file simply didn't appear on disk. Plus, on Windows you can't have a file called
NUL
(or
CON
COM
COM1
COM2
...)
Last edited on Nov 30, 2010 at 5:42pm UTC
Nov 30, 2010 at 6:08pm UTC
Plus, on Windows you can't have a file called NUL (or CON COM COM1 COM2...)
You can.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
C:\Temp\1>copy con \\?\C:\Temp\1\NUL
Hello world^Z
1 file(s) copied.
C:\Temp\1>dir
Volume in drive C has no label.
Volume Serial Number is BAB3-38DB
Directory of C:\Temp\1
30/11/2010 18:06 <DIR> .
30/11/2010 18:06 <DIR> ..
30/11/2010 18:06 11 NUL
1 File(s) 11 bytes
2 Dir(s) 103,358,296,064 bytes free
C:\Temp\1>
Topic archived. No new replies allowed.