Automatically Open Text File

This is a discussion on Automatically Open Text File within the C++ Programming forums, part of the General Programming Boards category; Hi, I am not sure where to ask this question, but here goes. I am working on a program that ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    27

    Automatically Open Text File

    Hi,

    I am not sure where to ask this question, but here goes. I am working on a program that outputs to a text file. I can do this without any issues.

    My question is, how can I automatically open the text file at the end of the program to see its contents? It is tedious to switch to the directory and double-click it every time to open it.

    Thanks,
    JackR

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Do you care what platform you get a solution for?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    ShellExecute() (at the end)
    Enter the full path to the text file, and it will open it in the app you have chosen to view text files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    i think a cleaner solution would be to use a batch file (windows) or a shell script (everything else) to first run the program then display the file.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    27
    Thank you for the advice. Shell script it is.

    JackR

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 05:27 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Function is called and I am trying to open a file
    By tommy69 in forum C Programming
    Replies: 88
    Last Post: 05-06-2004, 09:33 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

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