It depends on what device you are checking for. You have to enumerate the USB devices and check for matching types or device names. Use something like "c++ linux enumerate usb devices" with your favorite search engine to know how to do that.
For a quick check of the existing devices use the
lsusb command line tool (
lsusb(8): USB devices - Linux man page[
^]). You can also get the source code of that tool to see how the enumeration can be done.
[EDIT]
If you want to check for auto mounted USB storage devices list the entries of the directory where those devices are mounted (usually at
/media) ignoring other devices like loaded CD/DVDs.
To get informed when USB media are inserted or removed you can use
halevt or the old
ivman.
[/EDIT]