Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C/++/# How to read a list of USB from C++ in ubuntu OS?

  1. Dec 20, 2016 #1
    I am trying to use C++ (eclipse in Ubuntu OS) to read USB connection. Usually, on the terminal window, I can use command "lsusb" to see the list. Now, I want to do the same way with C++.

    can anyone help?

    Thank you very much.
  2. jcsd
  3. Dec 20, 2016 #2


    Staff: Mentor

  4. Dec 20, 2016 #3

    Stephen Tashi

    User Avatar
    Science Advisor

    But is the question how get the list of usb connections within a C++ program instead of from the command line?

    In C there is a command "system(...)" isn't there? it returns information in a string, so it is awkward to use.

    Edit: I see - you're suggesting he read the files from the C++ program. That would still mean getting information in the form of strings, I suppose.
  5. Dec 20, 2016 #4


    Staff: Mentor

    No, the system() function returns an int, typically a status code that is returned by whatever system command was called.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted