如何用C语言运行一个bat文件

来源:百度知道 编辑:UC知道 时间:2024/06/30 22:57:37
用C中的spawnlpe只能调用exe程序,那如果我把一个命令写在bat文件里,想让他运行,怎么做```

system("a.bat");

函数名: system
功 能: 发出一个DOS命令
用 法: int system(char *command);
程序例:

#include
#include

int main(void)
{
printf("About to spawn command.com and run a DOS command\n");
system("dir"); //这里就是DOS下的dir命令
return 0;
}

在程序中使用system()函数
假设bat文件的名称叫a.bat
即:
system("a.bat");

windows操作系统下system () 函数详解(主要是在C语言中的应用) 
函数名: system
功 能: 发出一个DOS命令
用 法: int system(char *command);
system函数已经被收录在标准c库中,可以直接调用