用c++制作cmd

cmd的主要还是system()函数,如:

system("shutdown -s -t 0");//关机代码

system()之可以使用char类型,所以要把string转换成char.

代码:

#include "bits/stdc++.h"
using namespace std;
int main()
{
    bool keep_going=true;string code;
    while (keep_going)
    {
        cout<<"代码:";
        cin>>code;
        if (code=="exit")
        {
            keep_going=false;
            continue;
        }
        system(code.c_str());
    }
}

下期再见,并感谢csdn对我的支持,我会坚持发送博客~

猜你喜欢

转载自blog.csdn.net/hzxhxyj1/article/details/131451168