真的,我已经想不出来做些什么了。
于是,我就
目丁
上了 cmd。
纯属娱乐,务必当真
代码:
#include <iostream>
#include <string>
#ifdef linux
#include <unistd.h>
#include <pwd.h>
#endif
#ifdef _WIN32
#include<Windows.h>
#endif
using namespace std;
string getUserName()//这段是抄的,来自 https://blog.csdn.net/qq_45662588/article/details/120041330?ops_request_misc=&request_id=&biz_id=102&utm_term=c++%20%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E7%94%A8%E6%88%B7%E5%90%8D%E7%A7%B0
{
#if defined linux //linux system
uid_t userid;
struct passwd* pwd;
userid=getuid();
pwd=getpwuid(userid);
return pwd->pw_name;
#elif defined _WIN32 //windows system
const int MAX_LEN = 100;
char szBuffer[MAX_LEN];
DWORD len = MAX_LEN;
if( GetUserName(szBuffer, &len) ) //用户名保存在szBuffer中,len是用户名的长度
return szBuffer;
#else //outher system
return "";
#endif
}
int main()
{
system("title cmd #伪# 纯属娱乐,务必当真");
cout<<"Microsoft Windows [版本 ?]\n纯属娱乐,务必当真。 \n";
while(1)
{
char str[54188];
cout<<"\nC:\\Users\\"<<getUserName()<<'>';
cin.getline(str,54188);
system(str);
}
return 0;
}
。。。感觉做的不太好