我有一个与此类似的循环。
int total1, total2;
for (total1 = fsize(myfile);;) {
total2 = fsize(myfile);
...
...
total1 = total2;
}
我想做的是将其转换为 while
循环,并在结束循环之前检查额外条件。
我想做这样的事情:
while((total1 = fsize(myfile)) && input = getch() != 'Q') {
total2 = fsize(myfile);
...
total1 = total2;
}
谢谢
最佳答案
for 循环的“初始化”部分 total1=fsize(myfile)
已成为 while 循环中测试的条件的一部分。这就是你的意图吗??
你确定你不想要这个吗...
total1 = fsize(myfile);
while((input = getch()) != 'Q') {
total2 = fsize(myfile);
...
total1 = total2;
}
关于c - for循环到while循环+附加条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3294833/