system调用和posix说明

来源:互联网 发布:27周胎儿发育标准数据 编辑:程序博客网 时间:2024/04/29 07:40

system库函数调用

system库函数调用,不同的运行环境,结果不同

#include <stdio.h>#include <stdlib.h>/* * 在windows下运行会开启10个计算器窗口 */int main() {    int i;    for(i = 0;i<10;i++)    {        //系统函数,不同的运行环境,结果不同        system("start calc");    }    return 0;//0代表成功,-1代表失败,其他为错误代码}
//a.c#include <stdio.h>#include <stdlib.h>/* * 在windows下运行会开启10个计算器窗口 */int main() {    int i;    system("b");    return 0;}//b.c//gcc -o b b.c #include <stdio.h>int main() {    printf("hello world");    printf("%x",100);//以16进制输出    return 0;}//控制台调用a,回输出"hello world".说明调用了b程序

posix说明

posix就是移植。在win下写的程序,移植到Linux下,运行结果不一定一样,所以最好采用Linux平台开发

0 0
原创粉丝点击