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

原创不易;还希望各位大佬支持一下!
边栏推荐
- 软件缺陷管理——测试人员必会
- Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
- Software defect management - a must for testers
- 渗透学习-sql注入过程中遇到的问题-针对sort=left(version(),1)的解释-对order by后接字符串的理解
- CUDA error:out of memory caused by insufficient video memory of 6G graphics card
- Summary of Web testing and app testing by bat testing experts
- How to prioritize the contents in the queue every second
- Go from introduction to practice -- definition and implementation of behavior (notes)
- [sword offer ii] sword finger offer II 029 Sorted circular linked list
- Crontab scheduled task common commands
猜你喜欢
![[MySQL] database function clearance Tutorial Part 2 (window function topic)](/img/03/2b37e63d0d482d5020b7421ac974cb.jpg)
[MySQL] database function clearance Tutorial Part 2 (window function topic)

登录凭证(cookie+session和Token令牌)

This set of steps for performance testing using JMeter includes two salary increases and one promotion
Conversion between flat array and JSON tree

Go from introduction to practice - error mechanism (note)

How to participate in openharmony code contribution

Penetration learning - shooting range chapter - detailed introduction to Pikachu shooting range (under continuous update - currently only the SQL injection part is updated)

average-population-of-each-continent

使用Jmeter进行性能测试的这套步骤,涨薪2次,升职一次

Learn to go concurrent programming in 7 days go language sync Application and implementation of cond
随机推荐
渗透学习-靶场篇-pikachu靶场详细攻略(持续更新中-目前只更新sql注入部分)
[MySQL practice] query statement demonstration
Système de gestion - itclub (II)
How many ways does selenium upload files? I don't believe you have me all!
使用Fiddler模拟弱网测试(2G/3G)
Common problems encountered by burp Suite
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
\W and [a-za-z0-9_], \Are D and [0-9] equivalent?
Management system itclub (medium)
How to open an account for agricultural futures? How much is the handling charge for opening an account for futures? Who can give you a preferential handling charge?
Crawler notes (3) -selenium and requests
关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证
AQS SOS AQS with me
How to do function test well? Are you sure you don't want to know?
Basics of operators
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
Gbase 8A OLAP analysis function cume_ Example of dist
OpenSSL programming I: basic concepts
gomock mockgen : unknown embedded interface
The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)