当我想在 Windows PC 上的 C++ 程序中终止输入时,Ctrl+Z 曾经很有效。现在我在 Mac 上写代码,我使用 ctrl+D 来模拟 EOF 信号,但它表现得很奇怪。输入确实停止了,但程序似乎没有继续。当我按下 ctrl+D 时,程序似乎一下子停止了。如果有帮助的话,我正在编写一个简单的 union 查找集。
#include <iostream>
#include "UnionFindSet.h"
using namespace std;
int main() {
int n;
int x,y;
std::cin>> n;
UnionFindSet UFSet(n);
while(std::cin>> x >>y)
{
UFSet.makeUnion(x,y);
}
std::cout<< UFSet.getConnectedPartNumber()<<std::endl;
return 0;
最佳答案
在 Mac 上,CLion 将 Ctrl-D 映射到 Command-D Command-D 发送 EOF。 这可以在 Preferences --> Keymap
下配置关于c++ - 如何在 Mac 上的 Clion 中使用 ctrl+D 终止输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34498574/