您的位置:首页 > 手游攻略 > 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

20190630145804

2、指定生成文件

gcc 01_hello.c -o 01_hello

image

运行

1、当前目录

./ 01_hello

image

2、绝对路径

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

image

注意

如果没有安装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---------");}

运行结果

image

最新游戏

更多

Copyright©2010-2019. All rights reserved | 波波三国游戏官网|[email protected]

备案编号:湘ICP备2022015115号-4