C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-29-2006, 02:32 PM   #1
Registered User
 
Join Date: Jan 2006
Posts: 5
Saving a Console Application!!

Let's say you make a console application and enter stuff in it and stuff like

cout<<"Enter emergency: "
balal balal bla
bala

then u want to save this fast in .txt form or whatever form into ur computer so u can check later. Is there anyway?
ekweb is offline   Reply With Quote
Old 01-29-2006, 02:42 PM   #2
xhi
!anExpert
 
Join Date: Mar 2005
Location: pa
Posts: 155
when you execute the file redirect the output into a file like so

runprogram.exe > file.txt
xhi is offline   Reply With Quote
Old 01-29-2006, 02:42 PM   #3
Registered User
 
Join Date: Jan 2006
Posts: 5
can u give that in code form cuz i dont get it
ekweb is offline   Reply With Quote
Old 01-29-2006, 03:01 PM   #4
It's full of stars
 
adrianxw's Avatar
 
Join Date: Aug 2001
Posts: 4,833
You can, at anytime, read the entire contents of the console screen and if you wish, write it to a file so next time you open the application it will start with the self same screen.

My console tutorial here covers this, the section towards the end of page 2 will give you ideas.
__________________
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
adrianxw is offline   Reply With Quote
Old 01-29-2006, 03:12 PM   #5
Registered User
 
Join Date: Jan 2006
Posts: 5
i couldnt get anything
ekweb is offline   Reply With Quote
Old 01-29-2006, 03:15 PM   #6
xhi
!anExpert
 
Join Date: Mar 2005
Location: pa
Posts: 155
Quote:
Originally Posted by ekweb
can u give that in code form cuz i dont get it
i was referring to when you run the program from the command line..

eg.
c:\myprog.exe > c:\output_file.txt

> works same way in nix..

is that the result you were looking for?
xhi is offline   Reply With Quote
Old 01-29-2006, 03:40 PM   #7
Registered User
 
Join Date: Aug 2005
Posts: 1,265
the problem with xhi's solution is that ALL screen output will go to a file, so if you are prompting someone to enter something that prompt will also go to a file and you will never see it on the screen. I doubt that is what the wkweb really wants. He didn't really say, but I suspect he wants to save it to a file AFTER typing the data on the keyboard.

Use fstream to save the contents of program variables to a file and read them back in another session of the program.
Ancient Dragon is offline   Reply With Quote
Old 01-29-2006, 03:49 PM   #8
xhi
!anExpert
 
Join Date: Mar 2005
Location: pa
Posts: 155
i was drawing that conclusion from the fact he never asked about file IO, specified that he wanted a *fast* solution and also only had a cout in the example code..
xhi is offline   Reply With Quote
Old 01-29-2006, 05:31 PM   #9
Registered User
 
Join Date: Jan 2006
Posts: 5
well its something for beginners lets say instead of opening a notepad u open the console application exe and write something and press enter. The info u write i want saved on desktop or where ever in .txt or console or watever. I think now u know what i mean. I hope. Really basic but im a beginner which is y i ask ur help. TY
ekweb is offline   Reply With Quote
Old 01-29-2006, 05:37 PM   #10
xhi
!anExpert
 
Join Date: Mar 2005
Location: pa
Posts: 155
in that case as Ancient Dragon suggested, research on fstream..
xhi is offline   Reply With Quote
Old 01-29-2006, 05:40 PM   #11
Registered User
 
Join Date: Jan 2006
Posts: 5
k ill check
ekweb is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Win32 Console Application Problem. kevinawad C++ Programming 10 11-07-2008 03:35 PM
console application... k1ll3r C++ Programming 4 05-23-2006 10:41 AM
'No symbols Loaded'. Simple console application flipflop82 C++ Programming 3 10-20-2004 09:10 AM
making a stealthy win32 console application? killdragon C++ Programming 3 09-08-2004 02:50 PM
Move cursor in console application alfa C# Programming 2 02-09-2003 02:58 PM


All times are GMT -6. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22