我想在这里加上按下空格键从*切换到X,再次按下时从X切换到*

cout<< "" < //我想在这里加上按下空格键从切换到X,再次按下时从X切换到*
cout<< x << endl;

可以用system("cls")清屏,然后while(1)判断有没有输入空格键就行了

#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main(){
    int mode=0;//用于判断现在是*(0)还是X(1)
    cout<<"*";
    while (1){
        char ch=_getch();//无缓冲接收输入信息
        if (ch==' '){//如果ch是空格键 
            system("cls");
            if (mode==0){
                cout<<"X";
                mode=1;
            }else{
                cout<<"*";
                mode=0;
            }
        } 
    }
} 

这是我的方法,看看能不能运行