You are here:



please explain how can we use the inbuilt function system()in c++
i am having a turbo c++ compliler and i wish to run the dos commands "c:\>start"
from my c++ program
actually i am trying to make a program that would be able to send e-mails, to the people registered in the database, on their birthdays, automatically .
thank you

The system function takes a single C-style string parameter (i.e. a zero terminated array of characters), runs a command interpreter (aka command shell or shell) and passes the string to it to execute. In this it is totally system dependent, in that it uses the command shell available for the user on the local system.

For example:


The above is a useful way to pause program execution until the user enters a character and is useful for instance in example programs run from within a development environment and the command window would close before the user had time to see the output. It will however not work on say a Linux or UNIX system whose command shells do not have pause as a command.

The fact that system will run a command shell implies that the string passed to the system function represents a valid command for the shell to execute. Your example is not a valid msdos/cmd shell command. It is what you see on the screen if you have not set prompts to be anything else (at least in a command prompt for modern Microsoft systems such as Windows 2000 or XP), followed by a command. The command part would be:


I tried this command in a command window on my Windows XP system and it does not understand it. Maybe your system is different and this command does work on your system. However this does not look like a usual console application command line (or rather the part after start does not). In fact this part (mailto: onwards) looks like a URL that would be entered into to a web browser.

So first get your use of the system function working with built in commands such as pause or dir. Next get the command you wish to use with the system function working from a command window (aka DOS box). Then make the two work together.

For your information, as far as I know and can tell from a quick WWW search you cannot send email from the command line in a Windows system without additional programs being installed. You can find command line mailers for MS Windows using a search engine site such as Google ( and a search such as (only an example query - you may well need to vary it to get best results):

   email windows command line

If you have MS Outlook Express installed then this article seems to explain using it from the command line to send an email:

If you have MS Office Outlook installed then there are articles that list the command line options you can use with it such as the page at:

Note that these topics are outside my area of expertise so I cannot help any further than this with this part of your query. If you wish to know more on using such programs from the command line then ask an expert in that area (e.g. a Windows expert of some sort).


All Answers

Answers by Expert:

Ask Experts


Ralph McArdell


I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.


My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at


©2016 All rights reserved.