0

i have written small c language code to execute "dir" command which displays directories and files in the current directory, using system() function in c. But my code doesn't work. please help me.

# include <string.h>
# include <stdio.h>
# include <stdlib.h>
void main()
{
clrscr();
system("dir");
getch();
}
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by gerard4143
0

i have written small c language code to execute "dir" command which displays directories and files in the current directory, using system() function in c. But my code doesn't work. please help me.

# include <string.h>
# include <stdio.h>
# include <stdlib.h>
void main()
{
clrscr();
system("dir");
getch();
}

You mean you wrote a 'batch' file using C, is dir a valid command for you operating sytem?

When running your program - what does it do...
1. does if fire off a run time error - if it does which one.
2. nothing - meaning the program executes but doesn't display the directory contents.

"my code doesn't work" may be fine for someone sitting beside you watching the process but we are located all over the world, please be provide details...

Edited by gerard4143: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.