Solved

executing a dos program with execl

Posted on 1998-09-03
1
173 Views
Last Modified: 2010-04-10
Hi,
     First i would just like to say i am a beginner with c++ so i know there is probably a better way to do this but can you fix this first and then put any other suggestion at the end.

I have written some small dos programs.  I want to write a small menu system program to execute my programs.  I found the command execl in the help menu but i can't get it to work.  It just says file not found.  It compiles and runs but it just can't find the file, which does exist.  Can you edit this code so it does work.  Thanks (I am using turbo c++)





//FILE: options.cpp
//    Date: Sept 03-98
//Menu system to choose what program to run

#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include <ctype.h>
#include <process.h>


void select (char);

void main()
{
      char choice;

      do
      {
            cout << endl << "1) Cir_on";
            cout << endl << "2) Cir_od";
            cout << endl << "q) quit";
            cout << endl << "Enter number of program you wish to run: ";
            cin >> choice;
            select (choice);
      }
      while (toupper (choice) != 'Q');

}

void select (char choice)
{
      char path[80] = "c:\\nc\\anilam\\";
      char argv[40] = "cir_od.exe";
      switch (toupper (choice))
      {
            case '1':
            cout << endl << "executing cir_od...";
            execl(path,argv);
            perror("EXEC:");
            break;

            case '2':
            cout << endl << "executing cir_on";
            break;

            case 'Q':
            cout << endl << "okay bye";
            break;

            default:
            cout << endl << "choose again";
            cin.ignore (80, '\n');

      }
}


0
Comment
Question by:onestar
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1172005
The first param of execl is the full path of the program, the arg (2nd and onwards) parameters are the command line options passed to the program

Change

char path[80] = "c:\\nc\\anilam\\";
char argv[40] = "cir_od.exe";
.etc...
execl(path,argv);

Into

char path[80] = "c:\\nc\\anilam\\cir_od.exe" ;
char argv[40] = "" ;
.etc...
execl(path,argv);


0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now