问题描述
初学者警报
我正在C
中尝试使用3个功能和system()
函数的功能。它还包括一个Python
文件,该文件使用pyautogui模拟(alt + tab)。问题是
它在完成system("clear")
语句后以某种方式通过了switch
命令。
这是C
代码:
#include <stdio.h>
#include <stdlib.h>
int makeSwitch() {
int x;
printf("\nType and enter one of them:");
printf("\n\n(1) - (2)");
printf("\n\n> ");
scanf("%d",& x);
int y;
switch (x) {
case 1:
printf("I like 1");
y = 1;
break;
case 2:
y = 2;
printf("I like 2");
break;
default:
system("python3 tb.py");
y = 3;
break;
}
system("clear");
return y;
}
void makePrint(int b) {
system("clear");
if (b == 1) {
printf("I like one\n");
} else if (b == 2) {
printf("I like two\n");
} else if (b == 3) {
printf("Hotkey: alt + tab\n");
} else {
printf("Command not found\n");
}
}
int main() {
int x = makeSwitch();
makePrint(x);
return 0;
}
这是Python
代码:
pyautogui.hotkey("alt","tab")
输出(1):
I like 1I like one
输出(2):
I like 2I like two
输出(y!= 1 || y!= 2):
Hotkey: alt + tab
因此,default:
之后system("clear")
就可以了!我想知道为什么。
我的猜测是我必须冲洗一些保留空间并阻止system()
函数运行的东西。
感谢您阅读。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)