本文介绍了如何将输出复制到剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我是C ++的老头刚刚开始学习它我想知道如何将生成的密码复制到我的剪贴板?我发现网上的代码,我想稍微修改一下。
Hello, I'm pretty noob with C++ Just starting to learn it i want to know how i can copy the Generated Password to my Clipboard? I found that code from the web and i wanted to modify it little bit.
//Random Password Generator.
#include "stdafx.h"
#include <iostream>
#include <ctime>
//<<
int main();
void Title()
{
using namespace std;
cout << "Welcome to the Random Password Generator." << endl <<
"This application will generate you a random password up to 64 characters long." << endl;
}
int DefineC()
{
using namespace std;
cout << "How many characters would you like in your password?" << endl;
int c;
cin >> c;
while (c > 64)
{
cout << "Please enter a number between 0 and 64." << endl;
cin >> c;
}
return c;
}
void Generate(int c)
{
using namespace std;
srand((unsigned)time(0));
int t = 0;
while (t < c)
{
char a = rand() % 106 + 21;
cout << a;
int w = 0;
while (w < 20000000)
{
w++;
}
t++;
}
}
void Regenerate()
{
using namespace std;
cout << "Would you like to regenerate your password?" << endl <<
"(This will erase the one you have just generated.)" << endl;
char r;
cin >> r;
check:
if (r == 'y' || r == 'Y')
{
system("cls");
main();
}
else{
if (r == 'n' || r == 'N')
{
cout << "Thank you for using the Random Password Generator." << endl <<
"The Application will now exit." << endl;
exit(0);
}
else{
cout << "Please enter Y/N" << endl;
cin >> r;
goto check;
}
}
}
int main()
{
using namespace std;
Title();
int c = DefineC();
cout << "Your password is: ";
Generate(c);
cout << "" << endl;
Regenerate();
return 0;
}
推荐答案
::_tsystem(_T("echo my message to the clipboard|clip.exe"));
打开NotePad.exe并粘贴剪贴板中的文本以检查结果。
Open NotePad.exe and paste text from the clipboard to check the result.
这篇关于如何将输出复制到剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!