C++ 按鍵跳出while循環

#include <iostream>
#include "conio.h"

int main()
{
	while (true)
	{
		// 在此處填入需要循環的代碼
		
		if (_kbhit()) // 如果有按鍵被按下
		{
			if (_getch() == 'q') //如果按下了q鍵則跳出循環
			{
				break;
			}

		}
	}
	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章