• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

executing a dos program with execl

     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;

            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...";

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

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

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


1 Solution
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


char path[80] = "c:\\nc\\anilam\\";
char argv[40] = "cir_od.exe";


char path[80] = "c:\\nc\\anilam\\cir_od.exe" ;
char argv[40] = "" ;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now