1,105,633 Community Members

execute a dos command in turbo c++

Member Avatar
prajwaludupa
Newbie Poster
1 post since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

well i tried to execute the following code..

#include<process.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<stdio.h>
void main()
{
system("dir");
getch();
}

but it did not execute the system command... what went wrong??

plz mail me at [email]prajwaludupardx_369@yahoo.co.in[/email]

Member Avatar
vidit_X
Junior Poster
168 posts since Aug 2008
Reputation Points: 29 [?]
Q&As Helped to Solve: 28 [?]
Skill Endorsements: 0 [?]
 
0
 

Its working at my end ..

Can you specify the error?

And please use CODE tags.

Member Avatar
aaandroid8
Newbie Poster
1 post since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i have also trouble in running the dos commands in turbo c++ . when i compile it everything goes wright . but at the time of execution it shows blanks screen not any dos commands. Atually Borland turbo c++ do not support dos commnads beside you can use "dev c++" to execute dos commands.

Member Avatar
Duoas
Postaholic
2,039 posts since Oct 2007
Reputation Points: 1,022 [?]
Q&As Helped to Solve: 229 [?]
Skill Endorsements: 10 [?]
Featured
 
0
 

IIRC, it worked just fine. You aren't seeing output because of the way Turbo C/C++ initializes the console output.

The problem is that you are doing something wrong. Are you trying to get a directory listing? Or just show it to the user?

Member Avatar
tajendra
Junior Poster in Training
53 posts since Mar 2010
Reputation Points: 9 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

system() command used here should generate desired output for dir, And i agree with Duoas as per output on console is concerned.

Though to validate system call functionality, one can try to redirect the output to a file.

void main() 
{
system("dir >>test_dir.lst");
getch();
}

check 'test_dir.lst' for the desired output.

vaisakh31
Newbie Poster
1 post since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

Hi,
dos command using the system() function not works while run the code. make exe and run that one by doule click. it will works !!

Member Avatar
sri.voma
Newbie Poster
1 post since Feb 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

g

``

#

You
Post:
Start New Discussion
View similar articles that have also been tagged: