title: C++ find mounting path of USB flash device (linux)
body: <p>(sorry for bad English, I'm German)</p>
  
  <p>I'm trying to write a program on linux that writes data on any inserted USB flash device that is inserted.</p>
  
  <p>But this:</p>
  
  <pre><code>file = fopen("/run/media/abc/xyz/logFile.txt", "w");
  </code></pre>
  
  <p>will fail if the username is not abc, or the name of the device is not xyz or linux does not want my program to work.</p>
  
  <p>I found a program that outputs this:</p>
  
  <pre><code>sysfs /sys
  proc /proc
  devtmpfs /dev
  securityfs /sys/kernel/security
  tmpfs /dev/shm
  devpts /dev/pts
  tmpfs /run
  tmpfs /sys/fs/cgroup
  cgroup /sys/fs/cgroup/systemd
  pstore /sys/fs/pstore
  cgroup /sys/fs/cgroup/freezer
  cgroup /sys/fs/cgroup/cpu,cpuacct
  cgroup /sys/fs/cgroup/perf_event
  cgroup /sys/fs/cgroup/memory
  cgroup /sys/fs/cgroup/pids
  cgroup /sys/fs/cgroup/net_cls,net_prio
  cgroup /sys/fs/cgroup/blkio
  cgroup /sys/fs/cgroup/devices
  cgroup /sys/fs/cgroup/cpuset
  cgroup /sys/fs/cgroup/hugetlb
  configfs /sys/kernel/config
  /dev/mapper/fedora_msi--linux-root /
  selinuxfs /sys/fs/selinux
  systemd-1 /proc/sys/fs/binfmt_misc
  debugfs /sys/kernel/debug
  hugetlbfs /dev/hugepages
  tmpfs /tmp
  mqueue /dev/mqueue
  binfmt_misc /proc/sys/fs/binfmt_misc
  nfsd /proc/fs/nfsd
  /dev/sda1 /boot
  /dev/mapper/fedora_msi--linux-home /home
  sunrpc /var/lib/nfs/rpc_pipefs
  tmpfs /run/user/1000
  gvfsd-fuse /run/user/1000/gvfs
  fusectl /sys/fs/fuse/connections
  /dev/sdc1 /run/media/username/usbname
  </code></pre>
  
  <p>But using this looks like bad style to me and I don't know how to differ between "/dev/sdc1 /run/media/username/usbname" (the right one) and "/dev/sda1 /boot" (the false one).</p>
  
  <p>Note: The Program is does not have to run on non-Linux operating systems.</p>
  
  <p>Note: I do not want to write directly into /dev/sdc1</p>
  
  <p>I would be thankful if anyone knows how to find the correct mounting points, or if anyone gives me a link to (official) documentation.</p>