如果我有一个while循环,只有在按下q键时才会停止,我该怎么做。 不过,我不希望它很只有在按下某个键时才停止C
#define TRUE 1
#define FALSE 0
typedef int boolean;
int main(int argc,char* argv[]){
char *script = malloc(MAXPATH);
script = "ls";
boolean a;
a = TRUE;
while(a){ //this is the while loop i want to break incase of a keypress
system(script);
}
do something else
something else....
这将在Mac OS X上运行
两者的getchar()和GETC()停顿,这使得循环停止
响应程序
在哪个平台上?这个问题不能在摘要中回答。 – ibid 2012-03-16 04:10:08
哪个平台?没有不是平台特定的答案。标准C库没有提供答案。 – 2012-03-16 04:10:38
Mac os x。运行10.7.3“getchar()”和“getc()”为i686-apple-darwin11-llvm-gcc-4.2(GCC)4.2.1(基于Apple Inc. build 5658)(LLVM build 2336.1.00) – Cripto 2012-03-16 04:12:22