Saving a Console Application!!

This is a discussion on Saving a Console Application!! within the C++ Programming forums, part of the General Programming Boards category; Let's say you make a console application and enter stuff in it and stuff like cout<<"Enter emergency: " balal balal ...

  1. #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?

  2. #2
    xhi
    xhi is offline
    !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

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    5
    can u give that in code form cuz i dont get it

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    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.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    5
    i couldnt get anything

  6. #6
    xhi
    xhi is offline
    !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?

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    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.

  8. #8
    xhi
    xhi is offline
    !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..

  9. #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

  10. #10
    xhi
    xhi is offline
    !anExpert
    Join Date
    Mar 2005
    Location
    pa
    Posts
    155
    in that case as Ancient Dragon suggested, research on fstream..

  11. #11
    Registered User
    Join Date
    Jan 2006
    Posts
    5
    k ill check

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. console application...
    By k1ll3r in forum C++ Programming
    Replies: 4
    Last Post: 05-23-2006, 11:41 AM
  2. 'No symbols Loaded'. Simple console application
    By flipflop82 in forum C++ Programming
    Replies: 3
    Last Post: 10-20-2004, 10:10 AM
  3. making a stealthy win32 console application?
    By killdragon in forum C++ Programming
    Replies: 3
    Last Post: 09-08-2004, 03:50 PM
  4. Move cursor in console application
    By alfa in forum C# Programming
    Replies: 2
    Last Post: 02-09-2003, 02:58 PM

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