小编Jer*_*ert的帖子

C在终止时执行`system("do thing here")`

我一直试图摆脱示例代码并在Google上查找"C退出函数"来实现这一点但我在编译时总会遇到错误.在我的代码中,我使用它在代码启动时将环绕声从通道1转换为2.

{
   system("irsend SEND_ONCE newremote KEY_2 && gpio mode 6 output && gpio write 6 1");
}
Run Code Online (Sandbox Code Playgroud)

现在我想为它发送相同的命令,而是KEY_1gpio write 6 0当程序被终止切换我的音频回主输入.

main.c: In function ‘functionA’: main.c:276:5: warning: ‘main’ is normally a non-static function [-Wmain]
  int main( int argc, char **argv )
 ^~~~
main.c:327:1: error: expected declaration or statement at end of input  }  ^ 
At top level: main.c:276:5: warning: ‘main’ defined but not used [-Wunused-function]
  int main( int argc, char **argv )
 ^~~~
makefile:9: recipe for …
Run Code Online (Sandbox Code Playgroud)

c exit raspberry-pi

0
推荐指数
1
解决办法
78
查看次数

标签 统计

c ×1

exit ×1

raspberry-pi ×1