详情

首页手游攻略 C语言——入门

C语言——入门

佚名 2026-09-02 09:36:54

C语言——入门的重点在于把前置条件、操作顺序和容易误判的地方分清楚。

helloworld

代码分析

//头文件,使用某个函数前,包含相应的头文件//**<>**通过包含系统的头文件(标准的头文件),**""**包含自定义的头文件#include <stdio.h>//main函数int main(){//函数调用,往标准输出设备打印内容// 代表换行printf("hello c");//返回值return 0;}

编译

1、未指定输出文件会默认生成a.out

gcc 01_hello.c

2、指定生成文件

gcc 01_hello.c -o 01_hello

运行

1、当前目录

./ 01_hello

2、绝对路径

/usr/local/c_study/c_code/day03/01_hello

注意

如果没有安装gcc 需要安装gcc

yum install gcc

代码

#include <stdio.h>int main(){printf("hello c");return 0;}

--------------------------------------------------------------------------------------------------------------

system()函数

#include<stdlib.h>int system(const char *command);功能:在已经运行的程序中执行另外一个外部程序参数:外部可执行程序名字返回值:不同系统返回值不一样

例子

#include <stdio.h>#include<stdlib.h>int main(){printf("before sys--------");//在02_system程序中执行01_hello程序system("./01_hello");printf("after sys---------");}

运行结果

相关资讯
点击查看更多
游戏推荐
推荐专题
热门阅读
推荐下载