导入头文件
1.系统的标准库stdio.h(standard input output) time.h malloc.h math.h string.h stdlib.h
2.自己写的头文件
#include导入
#include <stdio.h>
// ===> 单行 - 注释的内容
/* * / ===> 多行注释 - 给函数 方法 添加注释
main函数
是所有程序的入口点
int 是返回值 告诉操作系统这个程序的执行结果
0表示正常结束
非零-1表示不正常结束
程序的执行顺序是从上至下的
{ } 表示独立的代码块
int main() {
*通常变量的定义 在最前面
*(为什么需要变量:存储数据 选择 录入)
*变量的类型:根据不同类型的数据 定义不同的变量
*命名规范:见名知意 驼峰命名 numberOfPerson
*定义变量时尽可能赋初值
printf("请输入税前薪资:\n");
*向终端输出字符串
*系统自动完成 这个功能是由系统自己实现的
--整数20 100 %d int 4个字节
* 浮点数 85.5 %f float 4个字节
* 字符 'y' 'n' '2' %c char 1个字节
*字符串 "love" %s string
*长整型 1G %ld long int 4个字节
*双精度浮点型 金融 %lf 8个字节
return 0; }
定义变量
int salary = 0;
给变量赋值
salary = 10;
输出
printf("salary is %d\n", salary);
内存空间
printf("double :%lu\n", sizeof(double ));
float score = 95.5666;
printf("my score is %.1f\n", score);
long size = 1024*1024*1024;
printf("the size of video is %ld\n", size);
double money = 123345;
printf("money is %f\n", money);
char rank = 'A';
printf("I have the %c rank\n", rank);
char *name = "Jack";
printf("my name is %s\n", name);