当前位置:网站首页>字符数组和字符串的区别
字符数组和字符串的区别
2022-07-28 14:29:00 【飞天_】
字符串的区别,说字符串字面量直接保存常量储区中,而使用指针是直接指向常亮存储区中的地址,使用数组是将这个字符串字面量的副本保存在数组里面,直接表现就是数组的地址和指针指向的地址不一样。而且书中说使用指针的方式是无法修改字符串的。(原话是“指针指向的字符串字面量不能更改”)
#define MSG "I'm special"
#include <stdio>
int main()
{
char ar[] = MSG;
const char *pt = MSG;
printf("address of \"I'm special\": %p \n", "I'm special");
printf(" address ar: %p\n", ar);
printf(" address pt: %p\n", pt);
printf(" address of MSG: %p\n", MSG);
return 0;
}
输出结果:
address of "I'm special": 0x100000f10
address ar: 0x7fff5fbff858
address pt: 0x100000f10
address of MSG: 0x100000f10
边栏推荐
猜你喜欢

【通道注意力机制】SENet

JWY-32B电压继电器

有奖活动分享:使用WordPress搭建一个专属自己的博客后最高可领取iPhone13

Grpc protocol buffer

流畅到让人头皮发麻的单商户商城,你用过吗?

What functions will be added to crmeb Standard Version 4.4

简单入手Swagger

In 2022, the average salary of global programmers was released, and China ranked unexpectedly

Tencent interview -- please design a thread pool to implement sequential execution

Deepfacelab model parameters collection
随机推荐
Hjs-de1/2 time relay
[Game Testing Engineer] get to know game testing for the first time - do you know it?
crmeb 标准版window+phpstudy8安装教程(三)
流畅到让人头皮发麻的单商户商城,你用过吗?
php parse_ URL bypass whitelist
【LeetCode】35、搜索插入位置
ArcGIS Pro 中的编辑器
一文看懂CRMEB开源在线教育知知识付费系统
Jogy-61 voltage relay
R introduction example details
3564. Date category
Opencv - draw mask images of multiple instances
[touch] count the number of engineering documents, code lines, and line comment coverage
Understanding of entropy and cross entropy loss function
Shellcode writing (unfinished)
4518. Minimum ticket price
DJ-131/60C电压继电器
day 7/12
Table lock query and unlocking in SQL development part 1
10、相关数据累积任务实现