本部分含有数据类型,变量和常量,字符串、转义字符、注释的基础笔记。
笔记部分:
代码部分:
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
//全局变量
int c1 = 100;
//3.2.3#define定义的标识符常量
#define MAX 1000
//3.2.4枚举常量
enum Time
{
oneday,
twoday,
threeday
};
int main()
{
//第一个c语言程序
printf("1.第一个c语言程序:\n");
printf("开始\n");
//数据类型
printf("2.数据类型:\n");
char b1 = 'a';
int b2 = 10;
float b3 = 1.5;
printf("%c,%d,%f\n",b1,b2,b3);
printf("int:%d\n", sizeof(int));
//变量和常量
printf("3.1 变量:\n");
//局部变量
int c1 = 10;
printf("c:%d\n", c1);
//加法运算
int c2 = 0;
int c3 = 0;
int sumC1 = 0;
scanf("%d %d", &c2, &c3);
sumC1 = c2 + c3;
printf("sum:%d\n", sumC1);
printf("3.2 常量:\n");
//3.2.1字面常量
10;
10.1;
'a';
//3.2.2const修饰的常量
const int c4 = 100;
//c4 = 10;//err
//int arr[c4]={0};//err
//3.2.3#define定义的标识符常量
int c5 = MAX;
printf("%d\n",c5);
//3.2.4枚举常量
enum Time oneweek=oneday;
//4.字符串+转义字符+注释
printf("4.字符串+转义字符+注释:\n");
//4.1字符串
char d1[] = "wuLA\0";
char d2[] = { 'w' , 'u' , 'L' , 'A' , '\0' };
printf("%s\n%s",d1,d2);
printf("\n%d\n", strlen(d1));
//4.2 转义字符
printf("\"\\test\\test?\"");
//4.3注释
//单行注释
/*多行
注释*/
return 0;
}