当前位置:网站首页>初识C语言 第二弹
初识C语言 第二弹
2022-06-27 19:53:00 【喵喵喵更多】
文章目录
一.常量
常量:描述不变的量。C语言中的常量分为以下几种:字面常量 const修饰的常变量 #define定义的标识符常量 枚举常量。
1.字面常量: 30; 3.14;‘w’字符;“abc”字符串;
2.const修饰的常变量
const修饰的a不能输出20,若没有const则会输出20,使变量a具有常量的属性
3.#define定义的标识符常量
输出100 100 define定义了标识符MAX 所以可以在其中输出
4.枚举常量
不能变化
二.字符串+转义字符+注释
字符串
int main()
{
//char 字符类型
//‘a’-字符常量
char ch=‘w’; //把字符w放到字符变量去定义
//“abcdef”;-称为字符串
//C语言中没有字符串类型
return 0;
}
字符串该怎么存起来呢?
把它放到字符数组中
char arr[10] --该数组中放10个字符; 例如:char arr[10]=“abcdef” 这样可以存放,前提是前面给的空间足够大 或者 char arr[]=“abcdef” --这样根据后边字符串的大小来自动确定前面的值
字符串的末尾隐藏了一个’’
‘’为字符串结束的标志
初始化的arr1所占的7个空间,而初始化arr2占了6个空间
%s打印输出字符
arr1和arr2的前后都有内存空间,而输出的只是占一小部分
arr1输出为那样是因为’’ 而arr2的输出没有’’,所以arr2输出为图中的那样,直到找到’’才打印结束
这是在加上’’之后就可以输出的一样了

想要运行这个程序,求这个字符串长度,若运用这个函数则需要在前面加一个头文件#include <string.h>
strlen获取的是字符串的长度 所以是6
上边的7是这个字符串所占的空间长度(size of)需要是7
转义字符:转变了原来字符的意思
C语言中规定的转义字符

转义字符
//三字母词(早期的解析器)
) -->]
( -->[


路径打印的时候一定是
为水平制表符,相当于tab
把八进制的数字转化为十进制的,找出以十进制代表的ASCII值代替的字符 图中的这是一个字符

若C语言中出现嵌套式的注释则会出问题 所以C语言的注释风格不支持嵌套
//-C++的注释风格
未来写代码的时候为自己的代码写注释(梳理思路、对复杂的代码进行解释)
三.选择语句
if的选择语句
if…else 若if(表达式为真)则执行if 若为假则执行else
C语言实现选择的语句:if…else Switch…
四.循环语句

五.函数

这是数学中对应的函数。而C语言中对应的函数如下:
首先先定义一个add函数,把int x int y 分别赋给n1 n2
add-函数名 x y为函数参数 {}中的是函数体 int为返回类型 上边定义的也可以改变成
六.数组

原创不易;还希望各位大佬支持一下!
边栏推荐
- Software defect management - a must for testers
- regular expression
- [cloud based co creation] what is informatization? What is digitalization? What are the connections and differences between the two?
- 深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
- Infiltration learning - problems encountered during SQL injection - explanation of sort=left (version(), 1) - understanding of order by followed by string
- average-population-of-each-continent
- 关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证
- Day 7 of "learning to go concurrent programming in 7 days" go language concurrent programming atomic atomic actual operation includes ABA problem
- Common problems encountered by burp Suite
- 软件缺陷管理——测试人员必会
猜你喜欢

管理系统-ITclub(中)

解决本地连接不上虚拟机的问题

average-population-of-each-continent

Yolov6: the fast and accurate target detection framework is open source

Solve the problem that the virtual machine cannot be connected locally

Learn to go concurrent programming in 7 days go language sync Application and implementation of cond

BAT测试专家对web测试和APP测试的总结

Crontab scheduled task common commands

Experience sharing of meituan 20K Software Test Engineers

Penetration learning - shooting range chapter - detailed introduction to Pikachu shooting range (under continuous update - currently only the SQL injection part is updated)
随机推荐
[sword offer ii] sword finger offer II 029 Sorted circular linked list
Conversion between flat array and JSON tree
Basics of operators
MONTHS_ Between function use
go语言切片Slice和数组Array对比panic: runtime error: index out of range问题解决
How many ways does selenium upload files? I don't believe you have me all!
Gbase 8A OLAP analysis function cume_ Example of dist
C # QR code generation and recognition, removing white edges and any color
Structured machine learning project (II) - machine learning strategy (2)
Gbase 8A method for reducing the impact on the system by controlling resource usage through concurrency during node replacement of V8 version
关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证
Selenium上传文件有多少种方式?不信你有我全!
6G显卡显存不足出现CUDA Error:out of memory解决办法
信通院举办“业务与应用安全发展论坛” 天翼云安全能力再获认可
Acwing week 57 longest continuous subsequence - (binary or tree array)
Gbase 8A OLAP analysis function cume_ Example of dist
Oracle obtains the beginning and end of the month time, and obtains the beginning and end of the previous month time
Vue+MySQL实现登录注册案例
渗透学习-靶场篇-pikachu靶场详细攻略(持续更新中-目前只更新sql注入部分)
軟件測試自動化測試之——接口測試從入門到精通,每天學習一點點