Opening files - Giving options?

This is a discussion on Opening files - Giving options? within the C++ Programming forums, part of the General Programming Boards category; Can anyone help please. I have made a prog that just displays text in the black dos window. Like the ...

  1. #1
    Registered User wwwGazUKcom's Avatar
    Join Date
    Sep 2001
    Posts
    2

    Question Opening files - Giving options?

    Can anyone help please. I have made a prog that just displays text in the black dos window. Like the "Hello World" does.

    However I want to add some options to open files, e.g .txt or .htm files etc.

    I know how to open another .exe from within my prog, but that's not what Im after what I really need is some sort of "options screen" to open files.

    I am using Dev C++

    Thanx.
    Gaz.
    Attached Images Attached Images  

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    That's not real clear. Do you want to view the file when the user gives input or presses a key or do u want to run a file using another app?

  3. #3
    Registered User wwwGazUKcom's Avatar
    Join Date
    Sep 2001
    Posts
    2

    Post Opening files - Giving options?

    I want to be able to view the file when the user gives input or presses a key e.g

    press 1 for readme.txt
    press 2 for Webpage.htm
    press 3 to extract winzip.exe

    Is it also possible to open directories?
    e.g
    press 4 to go to Pictures dir (D:\Pictures)

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    ok a little psedocode to get you going...

    #include <all relevent libraries>
    using namespace std;

    int main()
    {
    int choice=1;
    do
    {
    cout<<" A menu etc."
    cout<<"enter choice"
    cin>>choice;
    switch(choice)
    {
    case 1: //do whatever
    break;
    case 2: // do whatever
    break;
    case 3: // do whatever
    break;
    case 4: system("dir pathname /p");
    break;
    case 5: cout<<"sure you want to quit?"
    cin>> a char
    if(tolower(thatchar)=='y') choice=0;
    }
    }
    while(choice);
    return 0;
    }
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  2. Notepad++ opening ActionScript files
    By sean in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-26-2008, 03:49 PM
  3. Opening files.
    By omnificient in forum C Programming
    Replies: 9
    Last Post: 02-25-2008, 01:05 PM
  4. Opening ASCII files in C?
    By Mavix in forum C Programming
    Replies: 6
    Last Post: 04-25-2007, 02:23 PM
  5. Replies: 2
    Last Post: 11-05-2001, 01:02 PM

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