Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

executing a dos program with execl

Posted on 1998-09-03
1
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

610 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