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

原创不易;还希望各位大佬支持一下!
边栏推荐
- CUDA error:out of memory caused by insufficient video memory of 6G graphics card
- 结构化机器学习项目(二)- 机器学习策略(2)
- Go from introduction to practice - error mechanism (note)
- 【微服务】(十六)—— 分布式事务Seata
- 使用Fiddler模拟弱网测试(2G/3G)
- 百万年薪独家专访,开发人员不修复bug怎么办?
- Windwos 8.1系统安装vmware tool插件报错的解决方法
- Go from introduction to practice -- shared memory concurrency mechanism (notes)
- crontab定时任务常用命令
- AQS SOS AQS with me
猜你喜欢

Professor of Tsinghua University: software testing has gone into a misunderstanding - "code is necessary"

C # QR code generation and recognition, removing white edges and any color

【微服务】(十六)—— 分布式事务Seata

6G显卡显存不足出现CUDA Error:out of memory解决办法

Luogu p5706 redistributing fertilizer and house water

Ellipsis after SQLite3 statement Solutions for

Go language slice vs array panic: runtime error: index out of range problem solving

Solution to the error of VMware tool plug-in installed in Windows 8.1 system

Infiltration learning - problems encountered during SQL injection - explanation of sort=left (version(), 1) - understanding of order by followed by string

渗透学习-靶场篇-pikachu靶场详细攻略(持续更新中-目前只更新sql注入部分)
随机推荐
OpenSSL programming I: basic concepts
Conversion between flat array and JSON tree
二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)
中金证券经理给的开户链接办理股票开户安全吗?我想开个户
Test automatique de Test logiciel - test d'interface de l'introduction à la maîtrise, apprendre un peu chaque jour
6G显卡显存不足出现CUDA Error:out of memory解决办法
渗透学习-靶场篇-dvwa靶场详细攻略(持续更新中-目前只更新sql注入部分)
Login credentials (cookie+session and token token)
regular expression
Basic knowledge of loop traversal and function
使用Fiddler模拟弱网测试(2G/3G)
北京邮电大学|用于成本和延迟敏感的虚拟网络功能放置和路由的多智能体深度强化学习
Conversation Qiao Xinyu: l'utilisateur est le gestionnaire de produits Wei Brand, zéro anxiété définit le luxe
Penetration learning - shooting range chapter - detailed introduction to Pikachu shooting range (under continuous update - currently only the SQL injection part is updated)
《7天学会Go并发编程》第六天 go语言Sync.cond的应用和实现 go实现多线程联合执行
美团20k软件测试工程师的经验分享
Système de gestion - itclub (II)
Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
从学生到工程师的蜕变之路
Summary of gbase 8A database user password security related parameters