当前位置:网站首页>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

边栏推荐
- SSH service configuration
- NFS 共享存储服务
- Which brand of air conduction earphones is better? These four should not be missed
- cocos2d-x 学习笔记——瓦片地图TiledMap
- Wechat applet custom compilation mode
- Wechat applet custom compilation mode
- 单元测试框架Jest搭配TypeScript的安装与配置
- Network - network layer
- Upload and download files from Ubuntu server
- Which is the best and most cost-effective air conduction headset recommended
猜你喜欢

Technology sharing | common proxy tools for interface testing

shell脚本——“三剑客”之awk命令

How about air conduction Bluetooth headset? It's the most worthwhile air conduction headset to start with

Build php7 private warehouse

CentOS7部署MySQL数据库服务器

Wechat applet custom compilation mode

DNS domain name resolution service

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

Iptables firewall

NFS shared storage service
随机推荐
NAT和PAT的原理及配置
Network - network layer
Build php7 private warehouse
MySQL主从
Test interview questions collection (V) | automated testing and performance testing (with answers)
Vmware workstation configuration net mode
一、PXE概述和安装
Technology sharing | interface testing value and system
DHCP principle and configuration
---Stack & queue---
Gerapy use
C language memcpy library functions and the role of memmove
HDU-5783 Divide the Sequence(贪心水题)
测试面试题集锦(三)| 计算机网络和数据库篇(附答案)
Qgraphicsview promoted to qchartview
手把手教你三步完成测试监控系统搭建
What's a good gift for Tanabata? Niche and advanced product gift recommendation
LNMP搭建过程详解
OSI七层模型
Network - data link layer



