Can I get my output in my program to be sent to another program like Wordpad or Microsoft word?

Recommended Answers

All 13 Replies

Yes, but its more complex than you can handle right now. Just concentrate on writing the output to a simple text file.

Yes, but its more complex than you can handle right now. Just concentrate on writing the output to a simple text file.

I pretty much got everything figured out...

the last thing i need is to print the output.
by either printing it through the program (which i hear is impossible)
or by sending it to wordpad or microsoft word.

>>which i hear is impossible
No its not -- there are lots of programs that do it. Why not just write it to a file then use word if you want to print it ?

>>Why not just write it to a file?

What do you mean "write it to a file"?

I have to have this ready for the league in like... 6 hours, lol.
So basically all I need is to do the "index" for numbering it (which i dont know how to do) and then print it.

More importantly is the numbering.

I appreciate all the help, by the way.

Member Avatar for iamthwee

To print it all you have to do is go file > printer > print.

?

Through my program?

I want the output of my program to either print, or be sent to wordpad or microsoft word.

Member Avatar for iamthwee

There are a few options I see.

1) Write the output to notepad (not wordpad or MSword!) then just choose print from the menu.

2) Actually get the program to print it straight from the printer.

Which one?

What do you mean "write it to a file"?

Like use fstream object and output the text to a file. Not all that difficult. If you don't know how to do that then I don't think you can complete the project on time.

There are a few options I see.

1) Write the output to notepad (not wordpad or MSword!) then just choose print from the menu.

2) Actually get the program to print it straight from the printer.

Which one?

i would prefer to get it to print straight from the program to the printer.

Just open a stream to "LPT1:" and send the data to it. Try this program and see if it comes out on your printer.

#include <fstream>
using namespace std;

int main()
{
    fstream out("LPT1:");
    if( out.is_open())
    {
        out << "Hello World\n";
    }
    return 0;
}

[edit]The program hangs up on the return statement on my computer -- running Vista Home Premium.[/edit]

[edit]More info here and more here [/edit]

i did that, but it didn't do anything..
plus it will be set up using the bowling alley's computer/printer.
so its pointless to set it up through my personal one.

can i just get it sent to notepad or something?
I heard its possible.

yes, as I said before just output the data to a text file then open it with Notepad and print it manually. Simple solution and your program desn't have to worry about printers. Same as my previous example but instead of the file name "LPT1:" use some other name such as "myfile.txt".

yes, as I said before just output the data to a text file then open it with Notepad and print it manually. Simple solution and your program desn't have to worry about printers. Same as my previous example but instead of the file name "LPT1:" use some other name such as "myfile.txt".

I did that but it does nothing.

this is what I have

#include <iostream> 
#include <string> 
#include <istream>
#include <fstream>

using namespace std; 

int main()
{
      const int MAX=4;    
      std::string names1[20] = 
{"Anderson, Scott",
"Batista, Peter",
"Bland, Michael",
"Bolton, Elise",
"Brown, Jenny",
"Carcagente, Michelle",
"Caro, Jonathan",
"Dodson, Matt",
"Esbrandt, Cody",
"Galganski, Erik",
"Garcia, Eddiedelso",
"Harris, Pauline",
"Ihrig, Jon",
"Macina, Samm",
"Nelson, Austin",
"Rambo, Kenny",
"Seymour, Amy",
"Sprague, Nicole",
"Tuckfield, Matt",
"Valenti, Chris"
};   
      int score[20];
      string names2[20] = 
{"Burgos, Vanessa",
"Coleman, Morgan",
"Connor-Siefried, Wade",
"Cummins, Joey",
"Davis, Stephen",
"Garcia, Alberto",
"Girata, Andrew",
"Gopaul, Jeremy",
"Greenspan, Max",
"Kramer, Sara",
"Lauseng, Justin",
"Mandell, Justin",
"Manzo, Billy",
"Ramos, Roberto",
"Sather, Rachel",
"Sessions, Shawn",
"Smith, Christy",
"Sutphin, Kaidee",
"Wright, Julie",
"Zotti, Steve"
};
      int score2[20];
      int points1[20];
      int points2[20];
      double date=0.0;
      double game=0.0;
      
      cout << "JUNIOR GOLD BOWLING LEAGUE" << endl;
      cout << endl << endl;
      cout << "DATE ";
      cin >> date;
      cout << endl << "GAME # ";
      cin >> game;
      cout << endl << "ENTER SCORES FOR DIVISION 1" << endl << endl;
      
      for(int i = 0; i < 20; i++) 
      {   
            cout << names1[i] << ": ";     
            cin >> score[i];     
            cin.ignore(); 
            }
      cout << endl;      
      cout << "ENTER SCORES FOR DIVISION 2" << endl << endl;
      
      for(int i = 0; i < 20; i++) 
      {   
            cout << names2[i] << ": ";     
            cin >> score2[i];     
            cin.ignore(); 
            }
            system("cls");
            
              //sort by score (div 1)  
              for ( int i = 0; i < 20; i++ ) 	
              { score[i];   
                    for ( int j = 0; j < 20; j++ )     
                    {       
                            if( score[i] > score[j] )       
                            {          
                                       string tmp_string;          
                                       int temp;           
                                       temp = score[i];            
                                       tmp_string = names1[i];           
                                       score[i] = score[j];           
                                       names1[i] = names1[j];           
                                       score[j] = temp;          
                                       names1[j] = tmp_string;
                            }    
                    }   
              } 
              //sort by score (div2)  
              for ( int i = 0; i < 20; i++ ) 	
              { score2[i];   
                    for ( int j = 0; j < 20; j++ )     
                    {       
                            if( score2[i] > score2[j] )       
                            {          
                                       string tmp_string;          
                                       int temp;           
                                       temp = score2[i];            
                                       tmp_string = names2[i];           
                                       score2[i] = score2[j];           
                                       names2[i] = names2[j];           
                                       score2[j] = temp;          
                                       names2[j] = tmp_string;
                            }    
                    }   
              }
               
           
              //output
              cout << "JUNIOR GOLD BOWLING LEAGUE" << endl << endl;
              cout << "Date: " << date << "   Game #: " << game;
              cout << endl << endl;
              cout << "DIVISION 1" << endl <<endl;
              int numberOfPeople = 20;

              for ( int k = 0; k < 20; k++ )   
              {
                      cout <<names1[k] << ": " << numberOfPeople << " POINTS" <<endl;
                      numberOfPeople = numberOfPeople - 1;
       
                      }
              cout << endl << endl;   
              cout << "DIVISION 2" << endl << endl;
              int numberOfPeople2 = 20;

              for ( int k = 0; k < 20; k++ )   
              {
                       
                      cout <<names2[k] << ": " << numberOfPeople2 << " POINTS" <<endl;
                      numberOfPeople2 = numberOfPeople2 - 1;
       
             }
            
            fstream out("JrGoldLeague.txt");
    if( out.is_open())
    {
        out << "JrGoldLeague.txt\n";
    }
    return 0;
    
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.