惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - highmayor

在ABAP的SQL语句中写Oracle Hints Screen numbers ABAP 培训笔记 part 7 更改选择屏幕的GUI STATUS---RS_SET_SELSCREEN_STATUS 隐藏标准选择屏幕的执行按钮 SAP秀才-FI速成手册 FOR ALL ENTRIES的效率问题 - highmayor SAP学习笔记(HR Develepment学习笔记1) 程序间的调用 abap技术问题中文 - highmayor - 博客园 函数组的文件结构 - highmayor 闲说继承 oracle中使用SQL递归语句 - highmayor oracle删除重复行 深度理解按位异或运算符 使用sqlplus copy 命令在两个数据库间转移数据 Oracle数据库 Exp/Imp工具性能调优 通过JDBC操作ORACLE数据库 算法的时间复杂度(计算实例)
一个容易忽略的陷阱:修改字符串常量的值 - highmayor - 博客园
highmayor · 2010-06-16 · via 博客园 - highmayor

见下面例子:

int main()
{
    char *p = "1234";
    p[2] = '1';
    return 0;
}

编译时通过,但执行时发生coredump, 原因是试图修改字符串常量的值:  "1234"为一字符串常量,编译器有可能把它放在内存的只读区域,而p[2] = '1'试图对此字符串常量作修改,则会产生错误(当然啦,编译器也有不一定会把它放到只读区域,但这种情况应当避免)。。

另外,如果程序中有出现 两个或更多的字面值完全相同的字符串,如:
        char *p1 = "house";
        char *p2 = "house";
        那么编译器也有可能将它们存储在相同的位置,即“共用同一个字符串常量”,这样的话,如果修改其中一个字符串,就会影响到其它字符串。
    然而,如果使用一个字符串来初始化一个数组,则是可以修改数组的内容的。
        char a[] = "house";
        s[0] = 'm';