当前位置:网站首页>初识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为返回类型 上边定义的也可以改变成
六.数组

原创不易;还希望各位大佬支持一下!
边栏推荐
- Conversation Qiao Xinyu: l'utilisateur est le gestionnaire de produits Wei Brand, zéro anxiété définit le luxe
- Gbase 8A OLAP analysis function cume_ Example of dist
- Hash table - sum of arrays
- Acwing week 57 longest continuous subsequence - (binary or tree array)
- Yolov6: the fast and accurate target detection framework is open source
- 解决本地连接不上虚拟机的问题
- 深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
- Exclusive interview with millions of annual salary. What should developers do if they don't fix bugs?
- Management system itclub (Part 1)
- 管理系統-ITclub(下)
猜你喜欢

Codeforces Round #717 (Div. 2)

深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图

结构化机器学习项目(二)- 机器学习策略(2)

The "business and Application Security Development Forum" held by the ICT Institute was re recognized for the security capability of Tianyi cloud

【微服务】(十六)—— 分布式事务Seata
![The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)](/img/e6/4eb2ddf4d9bac5e40bf2e96656d294.png)
The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)

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

This set of steps for performance testing using JMeter includes two salary increases and one promotion

Read write separation master-slave replication of MySQL

Système de gestion - itclub (II)
随机推荐
MySQL greater than less than or equal to symbol representation
Typescript learning
Software defect management - a must for testers
[MySQL] database function clearance Tutorial Part 2 (window function topic)
CDH集群之YARN性能调优
Codeforces Round #721 (Div. 2)
关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证
Management system itclub (Part 1)
Solution to the error of VMware tool plug-in installed in Windows 8.1 system
从学生到工程师的蜕变之路
Go from introduction to actual combat - task cancellation (note)
结构化机器学习项目(二)- 机器学习策略(2)
Which method is called for OSS upload
Basics of operators
Go from introduction to actual combat - execute only once (note)
Go from introduction to actual combat - only any task is required to complete (notes)
Yolov6: the fast and accurate target detection framework is open source
mysql 大于 小于 等于符号的表示方法
This set of steps for performance testing using JMeter includes two salary increases and one promotion
About the SQL injection of davwa, errors are reported: analysis and verification of the causes of legal mix of settlements for operation 'Union'