程序从写出来->有结果的过程。
1.开发工具IDE:DevC++ Android Studio
2.创建项目 写代码
3.运行
4.结果
1.写代码——文本编辑器
#include <stdio.h>
Int main(){
printf(“hello world”);
return 0;
}
2.预编译——>编译器(制定规则)
gcc -E test.c -o test.i
b.展开
3.编译->高级语言转化为 汇编代码
a.检查语法错误
b.转化为汇编代码
4.汇编->把汇编代码转化为二进制数据
gcc -c test.s -o test.o
二进制数据
0101000101110
5.链接->把所有的目标文件链接为可执行的程序
gcc -o test test.o
注释
//单行注释
/* 多行注释(不可嵌套)
include 使用
include 宏 导入头文件
如果系统已经提供某些功能的实现只需要使用include将这些功能所在的头文件导入进来就可以了
<系统提供的类库>
stdio.h stdlib.h math.h string.h
”自己定义的头文件“
calculate.h
include <stdio.h>
编译器首先从系统的类库里面去查找这个头文件,如果没有,再到自己的文件中去查找,否则报错
include “stdio.h"
编译器首先从自己的类库里面去查找这个头文件,如果没有,再到系统的文件中去查找,否则报错
*/
/*
main()函数=代码块=完成特定功能
所有程序的入口点都是main函数
int返回值=记录当前程序的运行状态 0:正常结束 资源自由分配 非零:异常结束 没收
int argc:参数个数 argument count
char*argv[]:每个参数组成的字符串数组
*/
#include <stdio.h>
#include <stdbool.h>
int main(int argc,char*argv[]){
printf("%d",argc);
printf("%s",argv[0]);
/*
printf(”%d“,argc);//%d 转义字符
printf(”%s“,argv[0]);
*/
/*
printf 输出语句
终端 console口
scanf 输入:终端输入
\n 换行
\t 一个缩进
*/
printf("\nhello \nworld\n");
return 0;
}
变量类型
//为什么?
//变量 记录数据
//基本数据类型->只能存一个值
//int 整型数据12345
//long 长整型
//float 单精度浮点数1.5 94.3 82.0
//double 双精度浮点数1.4
//char 字符'd' 'a'
//string 字符串 "jack" "rose"
//short 短整型
//bool 是(成立/true) 不是(不成立/false)
//占据内存空间不一样
printf("%d\n",sizeof(int));//4
printf("%d\n",sizeof(long));//4
printf("%d\n",sizeof(float));//4
printf("%d\n",sizeof(double));//8
printf("%d\n",sizeof(short));//2
printf("%d\n",sizeof(char));//1
printf("%d\n",sizeof(bool));//1