Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在 linux 中编写一个 c 文件,我需要在我的代码中放入 2 个命令,但我不知道该怎么做。
命令是
sudo hciconfig hci0 piscan
和
sudo hciconfig hci0 noscan
提前致谢
采用
system("sudo hciconfig hci0 piscan");
或者
FILE *pipe; pipe=popen("sudo hciconfig hci0 piscan", "r");
要从 获取命令的输出pipe,您可以使用函数fgets, fread, ... 您可以像从文件中读取一样从管道中读取
pipe
fgets
fread