Thread: open a file NOT for in/output

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    3

    Question open a file NOT for in/output

    I have created a simple key logger and I the user has the option to open the log file after it has closed. if anyone knows how to do this please help. the only thing i can find is to open it for output. but it's already output so i just want to open it for viewing. Thanks A LoT

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    do you mean viewing it in your program? if you output it to a file, the user should be able to just view it using notepad or something, but if you want to use it in your own program, it depends on which functions you are using.

    if you are using the fstream stuff, you need to use ifstream

    if you are using FILE* functions, you need to do fopen("file.txt","rb");
    and fread

    a simple search of the FAQ brought up this:

    http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    http://faq.cprogramming.com/cgi-bin/...&id=1043284392

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    3

    Question open it with notepad

    It asks the user if they want to open the file with notepad. is there any way i can do this through c++ automatically, or would the user have to open the file manually? if anyone could help, please do. thanks a lot.

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    8
    Couldn't you do this:
    Code:
    system("notepad " + file_name);
    ???? That'd work if it was a console prog. For a windows prog you could probably use the API (which function I don't know - haven't learned that yet )
    Last edited by dvldrmmr; 04-30-2004 at 01:29 PM.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    ShellExecute
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    mdbnkc- use the .txt file extension and you won't have the problem of the user trying to open the file. That box comes up when windows doesn't recognize the filetype and wants to know what do do with it. vbmenu_register("postmenu_363842", true);

  7. #7
    Registered User
    Join Date
    Apr 2004
    Posts
    3

    thanks

    thanks
    dvldrmmr i just used the system command and it works fine. is there any way to incorpoate the ! symbol to a case, for example:
    Code:
    case !'a'
    I know that doesn't work but i dont want it to be the default. thanks

  8. #8
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    there is no way to do a !'a' with switch statements, only way you could do it is have an if test and do something like charVar!='a' or something like that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM