Copying command line

HI! I have this problem, my code generates a random password and I would like the user to have the option to copy the line from the commando prompt by pressing 1 for example. And then being able to paste it into a word document.

is this possible? :)
$ ./a.out | xclip -in -selection clipboard
where do u mean I should write that?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

#include <iostream>
#include <string>
#include <windows.h>
#include <ctime>
using namespace std;



int main()
{
	locale swedish("swedish");
    locale::global(swedish);

	cout<<"WELCOME PRESS ENTER TO GENERATE A PASSWORD!" << endl << endl;
	  
	  cin.get();
   while (true)
   {
      
      srand(time(0));
	  char characters[71] = { '0','1', '2', '3','4','5','6','7','8','9','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'y', 'x', 'z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'Y', 'X', 'Z','!','#','¤','%','&','*','@','$','£' };
     
      string password;
      for (int n = 0; n <= 7; n++)
      {
         password = password + characters[rand() % 70];
      }
	  
	  
	 
      cout << "YOUR PASSWORD:" << endl;
	  cout << password << endl << endl;
	  cout << "PRESS ENTER TO GENERATE ANOTHER PASSWORD!" << endl;
	 


      cin.get();
   }
   return 0;
   system("pause");
}

I would make the program simply output the password, just that.
Then, simply redirect the output to the program that writes the clipboard.
don´t understand what you mean, haha sry im stupid
Topic archived. No new replies allowed.