system调用gcc编译器-待补充

来源:互联网 发布:淘宝上卖汽车用品 编辑:程序博客网 时间:2024/06/07 09:05
#include <stdio.h>#include <stdlib.h>#include <string.h>#define FILE_SIZE 1024int main(int argc, char *argv[]){    //定义缓冲区,以使用格式化输出char buf[FILE_SIZE];//判题程序名char file_addr[FILE_SIZE] = "data.c";//源代码文件char compile_file[FILE_SIZE];strncpy(compile_file, file_addr, strlen(file_addr) - 4);sprintf(buf, "/usr/bin/gcc -static -o %s %s", compile_file, file_addr);//调用gcc编译int result = system(buf);if(0 == result)    {        //调用编译后的可执行程序        system(compile_file);    }    else    {        printf("%d\n", result);    }return 0;}



0 0
原创粉丝点击