1、
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
char arr1[] = "abc";
//"abc" -- 'a' 'b' 'c' '\0',\0表示字符串的结束标志
//数据在计算机上存储的时候,存储的是二进制
//a - 97,A - 65
// //ASCII 编码,ASCII 码值
char arr2[] = { 'a','b','c',0};
printf("%s\n", arr1);
printf("%s\n", arr2);
return 0;
}
2、没有结束字符它的长度是随机值
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
char arr1[] = "abc";
char arr2[] = { 'a','b','c' };
printf("%d\n", strlen(arr1));//strlen - string length - 计算字符串长度
printf("%d\n", strlen(arr2));//随机值
return 0;
}
3、循环
3-1.while循环
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
int main()
{
int line = 0;
printf("加入比特\n");
while (line < 20000)
{
printf("敲一行代码: %d\n",line);
line++;
}
if(line>=20000)
printf("好offer\n");
return 0;
}
4、函数
#define _CRT_SECURE_NO_WARNINGS 1标签:return,SECURE,int,C语言,学习,第二天,printf,line,include From: https://blog.51cto.com/u_16014691/6131275
#include <stdio.h>
#include <string.h>
//函数体Add
int Add(int x, int y) Add是函数名,括号里的是函数参数
{
int z = x + y;
return z;
}
int main()
{
int num1 = 10;
int num2 = 20;
int sum = 0;
//sum = num1 + num2;
sum = Add(num1, num2);
printf("%d\n", sum);
return 0;
}