最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C语言--不同系统,函数的结果可能不一样
时间:2026-08-07 13:37:12 编辑:袖梨 来源:一聚教程网
C语言所有的库函数调用,只能保证语法是一致的,但不能保证执行结果是一致的。
同样的库函数在不同操作系统下执行,结果可能不一样。
system在linux中的执行结果
第一个程序,执行完,返回250#include <stdio.h>#include<stdlib.h>int main(){printf("before sys--------");system("./01_hello");printf("after sys---------");return 250;}------------------------------------------------------------------------------------------------------------------------------------------------在第二个程序中执行第一个程序,并输出第一个程序的返回值#include <stdio.h>#include <stdlib.h>int main(){int a=system("./02_system");//打印变量a的值printf("a=%d",a);}------------------------------------------------------------------------------------------------------------------------------------------------结果[root@localhost day03]# ./03_return before sys--------hello cafter sys---------//输出的是4864,不是250a=4864------------------------------------------------------------------------------
system在windows中的执行结果
windows 下安装gcc编译器
1、下载WinGW
2、安装WinGW,WinGW是一个安装器

3、运行WinGW,选择安装内容

安装

4、配置环境变量

5、查看是否安装成功

windows 环境编译并运行c程序
第一个程序#include <stdio.h>#include<stdlib.h>int main(){ printf("system---------");return 250;}第二个程序,执行第一个程序,并打印第一个程序返回的值#include <stdio.h>#include <stdlib.h>int main(){int a=system("system.exe");//打印变量a的值printf("a=%d",a);}编译和运行结果

编译产生的结果

相关文章
- pishi-normalno:AI Agent 工具实践指南 10-03
- contract-review:实践指南 10-03
- smart-annotator:AI Agent 工具实践指南 10-03
- atlas:AI Agent 工具实践指南 10-03
- pi-kit:实践指南 10-03
- chrona:实践指南 10-03