Copy outputed text to clipboard or .txt file
Apr 26, 2010 at 12:50am UTC
Hello,
I am working on a script compiler for my school's morning announcements. so far I have the function nailed, but it is stuck in the command line and it needs to go to a teleprompter. I need to either copy it to the clipboard, or save it as a .txt file. I will post the full code and highlight what needs to be copied.
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
#include <iostream>
using namespace std;
int cday;
int Loop = 0;
int TimesLooped = 0;
int index2 = 0;
int index3 = 0;
char sanc;
char test;
string resp;
string quit = "quit" ;
char responce;
string sancr = " " ;
string Lunch = " " ;
string Anchor1 = " " ;
string Anchor2 = " " ;
string Date = " " ;
string anc[10] = " " ;
char y;
int main ()
{
top:
cout << "What is today's full date?" << endl;
getline(cin, Date);
cout << endl;
cout << "Cycle day..." << endl;
cin >> cday;
cout << endl;
getline(cin, Anchor1);
cout << "First Anchor's Name?" << endl;
getline(cin, Anchor1);
cout << endl;
cout << "Second Anchor's Name?" << endl;
getline(cin, Anchor2);
cout << endl;
cout << "Today's lunch is..." << endl;
getline(cin, Lunch);
cout << endl;
anc:
cout << "Are there any extra announcements? y/n" << endl << "-" ;
cin >> responce;
switch (responce) {
case 'y' :
cout << "How many?" << endl;
cin >> Loop;
cout << endl << Loop;
index2=0;
TimesLooped=0;
Loop++;
do {
cout << endl << "Type an announcement" << endl;
getline(cin, anc[index2]);
cout << endl;
index2++;
TimesLooped++;
} while (Loop != TimesLooped);
goto printer;
break ;
case 'n' :
goto printer;
break ;
default :
cout << "invalid responce" ;
goto anc;
break ;
}
printer:
cout << "Is there a special announcement today? y/n" << endl;
cin >> sanc;
cout << endl;
switch (sanc) {
case 'y' :
cout << "who is the announcer?" << endl;
getline(cin, sancr);
getline(cin, sancr);
cout << endl;
TimesLooped=0;
cout << "Good Morning DMS!" << endl << endl << "I'm " << Anchor1 << endl << "and I'm " << Anchor2 << "!" << endl << endl;
cout << "Lunch Menu for today is, " << Lunch << endl << endl;
while (index2 != TimesLooped) {
cout << anc[index3] << endl << endl;
index3++;
TimesLooped++;
}
cout << "Now over to a special announcement from " << sancr << endl << endl;
cout << "Thats all for today DMS." << endl << "Have a good day!" ;
break ;
case 'n' :
TimesLooped=0;
cout << "Good Morning DMS!" << endl << endl << "I'm " << Anchor1 << endl << "and I'm " << Anchor2 << "!" << endl << endl;
cout << "Lunch Menu for today is, " << Lunch << endl << endl;
while (index2 != TimesLooped) {
cout << anc[index3] << endl << endl;
index3++;
TimesLooped++;
}
cout << "Thats all for today DMS." << endl << "Have a good day!" << endl << endl;
break ;
default :
cout << "INVALID RESPONCE. ERR 001" << endl;
goto printer;
break ;
}
cout << "Program finished" << endl;
}
What the bolded and underlined lines output is what i need copied
thanks,
adam
Apr 26, 2010 at 1:12pm UTC
Apr 26, 2010 at 1:44pm UTC
or you can look into file streaming (run a search for fstream), which gets things into a .txt file, or any kind of file technically.
Apr 26, 2010 at 7:24pm UTC
On either system, to copy to a file simply redirect as usual:
./myprog >> afile.txt
myprog.exe >> afile.txt
Where would I put the lines of code?
Apr 27, 2010 at 1:14am UTC
Topic archived. No new replies allowed.