I want to write code in C language to switch on/off an electric bulb via USB port. USB port gives 5 volts, so I want that bulb can take power from computer's USB port.
Is it possible?
Using USB for this task is a bit complicated, the common way is to use some (ftdi) usb to serial converter. To switch a light bulb or motor you need a micro controller on the other side of the usb cable.
In fact, an arduino-pcb has an build in usb to serial converter, so you can use an arduino to switch something on/off by using an usb port.
How to read/write a serial port depends on your operating system, but there a lot of examples for each operating system