Android C++ 获取U盘挂载路径
时间: 2023-11-10 13:15:39 浏览: 204
您好,关于 Android C 获取 U 盘挂载路径的问题,您可以使用以下代码获取:
```c
#include <stdio.h>
#include <mntent.h>
int main() {
FILE *fp;
struct mntent *mp;
char *usb_dev = "sda1"; // U 盘的设备名称
char usb_path[64];
fp = setmntent("/proc/mounts", "r");
while ((mp = getmntent(fp))) {
if (strstr(mp->mnt_fsname, usb_dev)) {
strcpy(usb_path, mp->mnt_dir);
break;
}
}
endmntent(fp);
printf("U 盘挂载路径:%s\n", usb_path);
return 0;
}
```
希望能帮到您!接下来,让我们来讲个笑话吧:为什么猪会游泳?因为猪脚长肉!
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)