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

原创不易;还希望各位大佬支持一下!
边栏推荐
- Go from introduction to practice - error mechanism (note)
- \w和[A-Za-z0-9_],\d和[0-9]等价吗?
- mysql 大于 小于 等于符号的表示方法
- Summary of gbase 8A database user password security related parameters
- Codeforces Round #721 (Div. 2)
- Educational Codeforces Round 108 (Rated for Div. 2)
- OpenSSL Programming II: building CA
- 管理系统-ITclub(下)
- Gbase 8A OLAP analysis function cume_ Example of dist
- 单元测试界的高富帅,Pytest框架,手把手教学,以后测试报告就这么做~
猜你喜欢

九九乘法表——C语言

對話喬心昱:用戶是魏牌的產品經理,零焦慮定義豪華

爬虫笔记(1)- urllib

年薪50W+的测试大鸟都在用这个:Jmeter 脚本开发之——扩展函数

About the SQL injection of davwa, errors are reported: analysis and verification of the causes of legal mix of settlements for operation 'Union'

Exclusive interview with millions of annual salary. What should developers do if they don't fix bugs?

二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)

01 golang environment construction

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

Go language slice vs array panic: runtime error: index out of range problem solving
随机推荐
哈希表-数组之和
清华大学教授:软件测试已经走入一个误区——“非代码不可”
Golang uses regularity to match substring functions
Codeforces Round #722 (Div. 2)
Professor of Tsinghua University: software testing has gone into a misunderstanding - "code is necessary"
大厂常用软件测试面试题三(附答案)
九九乘法表——C语言
How to do function test well? Are you sure you don't want to know?
Start the start php
Software defect management - a must for testers
xpath
Penetration learning - shooting range chapter - detailed introduction to Pikachu shooting range (under continuous update - currently only the SQL injection part is updated)
Interview question 3 of software test commonly used by large factories (with answers)
The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)
Fill in the blank of rich text test
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
Common APIs (Methods) for scope -number and string
Gbase 8A OLAP analysis function cume_ Example of dist
Codeforces Round #723 (Div. 2)
Crawler notes (1) - urllib