How to Read/Write from/to I/O Devices in Windows Using C

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Hello,

OK. So, in Linux all I/O devices are mapped into the Linux file system.

I believe that /dev is the folder where all I/O devices are mapped.

So, in Linux if you want to communicate with these devices in C, you simply call fopen().

But, in Windows the I/O devices aren't mapped to the file system anywhere (or am I wrong?).

So, if I want to talk to an I/O device, what do I pass to fopen()?

Do I use another function instead?

Thanks.
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
Why would they be? I always thought using fopen to talk to a serial port was kind of silly.

Why? It's an object that you read from and write to. The unix "everything is a file" abstraction is not without its flaws, but in many ways it's incredibly powerful - like being able to manipulate a serial port using simple terminal commands.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
I use this to talk to serial ports:....

There must be a register that's connected to the serial port, right?

If you want to "talk" to any hardware, that hardware must have memory locations that can hold bits, yes?