当前位置:网站首页>MOOC翁恺C语言第八周:指针与字符串:1.指针2.字符类型3.字符串4.字符串计算
MOOC翁恺C语言第八周:指针与字符串:1.指针2.字符类型3.字符串4.字符串计算
2022-07-28 05:28:00 【W.934】
一、指针
1.取地址运算:&运算符取得变量的地址
1)取地址运算
sizeof :是个运算符,给出某个类型或变量在内存中所占据的字节数。
如:sizeof(int)表示int在内存中占据几个字节(4个字节);sizeof(i)表示i这个变量在内存中占据几个字节(4个字节)。
运算符& :
scanf("%d",&i); 里的&是用来取得变量的地址,它的操作数必须是变量。
int i;printf("%x",&i);
地址的大小是否与int相同取决于编译器(64/32位架构)。
int i;printf("%x",&i);
&不能对没有地址的东西取地址。&的右边必须有明确的变量。
相邻的两个地址的差距是4.
2.指针:指针变量就是记录地址的变量
scanf
什么样的类型可以接收取地址得到的地址?是指针。
指针类型的变量 就是 保存地址的变量。
int*p=&i;
* 表示:p是一个指针;p指向的是一个int;i的地址交给了p。(p指向i)
访问那个地址上的变量*
3.指针与数组:为什么数组传进函数后的sizeof不对了
数组参数
二、字符类型
1.字符类型

字符的输入输出:
'1'和1 不同。'1'是一个字符。1是数字。

![]()
混合输入

如果%d后没有空格,那么只取到整数结束为止。
有空格的话,会把整数后面的空格也读了。
字符计算

大小写转换

2.逃逸字符


三、字符串
1.字符串
字符数组:

字符串:


字符串变量:

字符串变量:
由双引号括起来的东西,在C语言中叫做字符串的常量(或字符串的字面量)。



2.字符串变量
字符串常量:


用指针还是数组来表达字符串?


char*是字符串?

四、字符串计算
1.字符串输入输出
字符串输入输出

空字符串

2.字符串函数
strcmp

strcpy

strcat

边栏推荐
- QT使用MSVC编译器输出中文乱码问题
- MySQL主主
- FTP service
- Firewall - iptables firewall (four tables and five links, firewall configuration method, detailed explanation of matching rules)
- Hdu-1159-commonsubsequence (LCS longest common subsequence)
- 技术分享 | 使用postman发送请求
- Ubuntu MySQL setting remote access permissions
- Create, traverse and search nodes as required for single linked list
- Escape character notes
- NFS shared storage service
猜你喜欢

How to calculate the size of structure, segment and Consortium (common body)

Compilation and preprocessing of C language

SSH service configuration

shell脚本——正则表达式

Cocos2d-x learning notes Tile Map tiledmap

cocos2d-x 学习笔记——瓦片地图TiledMap

Applets: lifecycle

Icc2 analysis timing artifact analyze_ design_ violations

Installation and configuration of unit test framework jest with typescript

1、 PXE overview and installation
随机推荐
Which brand of air conduction earphones is better? These four should not be missed
Tcp/ip five layer model
Hdu-2036-reform spring breeze blowing all over the ground (polygon area template)
What is the most practical gift for Tanabata? A gift that will never go wrong is worth buying
Which is the best and most cost-effective air conduction headset recommended
[learning notes] VIM editor
Create, traverse and search nodes as required for single linked list
Test interview questions collection (I) | common required questions and procedures of software testing (with answers)
Network - network layer
Small tips
HDU-5783 Divide the Sequence(贪心水题)
MySQL common commands
FTP service
How to calculate the size of structure, segment and Consortium (common body)
MySQL主从
C language memcpy library functions and the role of memmove
Technology sharing | detailed explanation of actual combat interface test request methods get, post
Hdu-1097-a hard puzzle (fast power)
On cookies and session
Technology sharing | interface testing value and system



