By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

problem in using system() functiions

P: 60
hi everybody...
I've a problem in using system() functions.
my program was:
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.   clrscr()
  4.   system("dir");
  5.   getch();
  6. }
  7.  
but i got only a blank screen as output when run this code.
What is the problem in this?
Mar 31 '07 #1
Share this Question
Share on Google+
6 Replies


Expert 10K+
P: 11,448
hi everybody...
I've a problem in using system() functions.
my program was:
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.   clrscr()
  4.   system("dir");
  5.   getch();
  6. }
  7.  
but i got only a blank screen as output when run this code.
What is the problem in this?
The system function can only start executable binaries (and maybe .bat files,
I'm not sure about that). It certainly can't start commands that are internal to
your shell (cmd.exe), i.e "dir" is not an executable command. Start the shell
(cmd.exe) itself as: "cmd /c dir".

kind regards,

Jos
Mar 31 '07 #2

Expert 100+
P: 1,510
hi everybody...
I've a problem in using system() functions.
my program was:
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.   clrscr()
  4.   system("dir");
  5.   getch();
  6. }
  7.  
but i got only a blank screen as output when run this code.
What is the problem in this?
this works OK for me using GNU C and Turbo C V3.0 under windows XP

what compiler/operating system are you using?
Mar 31 '07 #3

P: 60
Currently im using TurboC (that is in a LAN connection under Novel network)
Apr 2 '07 #4

Ganon11
Expert 2.5K+
P: 3,652
Make sure you add a return 0; statement at the end of your program.
Apr 2 '07 #5

P: 60
I even tried that too....
Not only dir command, it seems that it was not working with any of the dos commands.... I dont know waht to do
Apr 2 '07 #6

cjbrx3115
P: 93
I even tried that too....
Not only dir command, it seems that it was not working with any of the dos commands.... I dont know waht to do
Did you try using the #include<windows.h>? And also, you don't have anything that would display as an output, try using some text as an output to see if that is your problem.
Apr 2 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.