TC2.0 provides a system() function. This function can execute
commands in DOS and COMMAND.COM from within a running C program. By using this function, we can very conveniently convert batch files
into executable files. The method is as follows:
For example, the batch file Sample.bat
c:
cd c:\dos
dir/p
The corresponding C program is as follows:
Sample.c
#include //the system() function is included in this library
main()
{
system("c:");
system("cd c:\dos");
system("dir/p");
}
Compile Sample.c into an executable file, and running this file will achieve the function of Sample.bat.
commands in DOS and COMMAND.COM from within a running C program. By using this function, we can very conveniently convert batch files
into executable files. The method is as follows:
For example, the batch file Sample.bat
c:
cd c:\dos
dir/p
The corresponding C program is as follows:
Sample.c
#include //the system() function is included in this library
main()
{
system("c:");
system("cd c:\dos");
system("dir/p");
}
Compile Sample.c into an executable file, and running this file will achieve the function of Sample.bat.


