?
Solved

cut/paste all output of .exe file from C++ prog.

Posted on 1998-06-28
9
Medium Priority
?
209 Views
Last Modified: 2010-04-01
I created an .exe file using Visual C++ on Windows 95.   When I execute the program, it ends with only the last 25 lines visible.  I need to be able to either scroll up through the full output in the window to cut and paste or redirect the output of the program into another file from which I could cut and paste the full output.  I'm told that the DOS version of the script command would work.
0
Comment
Question by:dlane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1166740
You can redirect ouput to a file using > or >>  For instance.

someexe > somefile.txt

puts the output of someexe.exe into an file called somefile.txt.  If somefile.txt already existed, its previous contents are lost.  The command

someexe >> somefile.txt

puts the ouput in the file somefile.txt, but it appends it to the end of what was already in the file.

Is that what you are looking for?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1166741
Note if the program is a windows (console) program, it could put the output directly on the clipboard.
0
 

Author Comment

by:dlane
ID: 1166742
I had already tried your suggestions to use you initial suggestions to use "<"  However, my program prompts the user for data before it runs completely.  When I use <, the text file created only includes up to the user prompt.  I need to capture both the user prompt and the results outputted after the data is entered.  Will directing to the clipboard do this?  If so, how is it done?

-dlane
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Expert Comment

by:nietod
ID: 1166743
Not automatically.  But there may be a way that isn't too hard.  Some questions first:

Is this a windows console or DOS application?

How are you handling input and output at the moment?  (streams?, console I/O? DOS I/O, windows I/O?)  
0
 

Author Comment

by:dlane
ID: 1166744
The program pops up a DOS window asking the enter a seed number for a random number generator.  Once the user enters the seed number, the program generates commands to move a "turtle" around a "floor" (array).  Depending on whether the turtle's pen is up or down,  it changes the last spot visited from a "*" to a "+"  It's a pretty basic C++ program that uses <iostream.h> if that helps.  As a beginning programmer, I'm pretty clueless to the specifics of your questions unfortunately.

You can see what I'm trying to do at:
http://www.cs.bu.edu/students/grads/ghuang/cs201/exam/midterm1.html

I have the program working and am now just trying to see all of the output to make sure it is working right.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1166745
One more question.  This should be the last.  Each time the turtle moves you output a new "floor" that shows the new path, right?  That is, you don't alter what is already displayed, instead you output new information and what was already there is scrolled up   Correct?

If that is the case, we can put the input and ouput in a file and you can copy that file to the clipboard manually.  A DOS program can copy information to the clipboard, but I don't have the details on how to do so and I suspect it is overkill for your needs.
0
 

Author Comment

by:dlane
ID: 1166746
Correct.  Each time the print floor command is hit, the present floor is printed and the previous output scrolls up.  Right now, when I run it, I can only see/cut/paste the last floor.  I think being able to get both the input and output to a file and then manually to the clipbord would be sufficient.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1166747
Let me outline what you need to do.  If that isn't enough, you can ask questions.

You can create a straem that will be used to log the program's input/output to a log file.  If you want to get fancy you can use parameters to the program to control the name of the file, eri even if it is used.  But lets start with a simple design where the same file is always used.  You can use a ofstream (output file stream) to write to the log file.  You could create the log file like

ofstream LogFil("LogFile.Txt",ios::trunc,);

Then whenever you get input from the user, you just write ot to the LogFil stream.  Whenever you have output you ouput it to the LogFil stream as well as cout.  

There are fancier ways to handle this.  But I suspect that in this case they are not worth it.  However, if you think this method will be easy enough to implement because your program does too much input/ouput or it is too complex, let me know, and we can discuss the other options.  (They may harder cases easier, but aren't worth it for easy cases.)

0
 
LVL 22

Expert Comment

by:nietod
ID: 1166748
If you need more help or would like me to review the code, you can e-mail it to me at nietod@theshop.net.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question