> Hi ,
> How can we execute a dos command from the c program.please
provide syntax deepak
hi deepak,
our frnds already told u that use system() function. nice
u must use system() function which is in dos.h header file. i am
giving a program on system(). see and try it. but deepak it does not
run directly when compiling.
1) first compile these code,
2) one .exe file creates ur compiler.
3) next run that .exe file in DOS prompt by simply type a command
at command prompt as "system".
plz reply after compile and execute these code.
file name : system.c
#include<dos.h> /* for function system() */
#include<stdio.h> /* for printf() */
void main()
{
printf(" press any key to display files and directories\n ");
getch();
system("dir");
printf(" press any key to clear the screen \n ");
getch();
system("cls");
printf(" press any key to create a directory \n ");
getch();
system("md c:\deepak");
printf(" press any key to get directory ");
getch();
system("cd c:\deepak");
}