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

推荐订阅源

Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
Project Zero
Project Zero
E
Exploit-DB.com RSS Feed
S
Secure Thoughts
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
WordPress大学
WordPress大学
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hacker News: Front Page
F
Full Disclosure
Latest news
Latest news
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
G
GRAHAM CLULEY
Forbes - Security
Forbes - Security
V
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
P
Privacy International News Feed
C
Check Point Blog
N
News and Events Feed by Topic

博客园 - Flouse

Java开发技术学习要点 0-1 背包问题的扩展 sql server平台用存储过程的分页 [新闻]Web 3.0带来新体验 SyncToy v2.0 发布 微软同步工具 - Flouse [推荐]一个JavaScript WEB日历控件 Mozilla Thunderbird 3.0 Alpha 2 简体中文版 用友软件推出SaaS业务平台 推荐一款不错的笔记软件给大家 [收集]DotNetNuke(DNN)学习和应用资源合集 [讨论]提升DNN速度的方法 [推荐].NET开源项目 - Flouse C# 开发和使用中的23个技巧(常用) 三层体系结构学习总结 关于三层体系结构 LINQ学习工具 任务管理器CPU曲线跑起正弦曲线 [转][新闻]20世纪最好的10个算法 思考·未来的计算机是什么样子的呢?
const char*, char const*, char*const的区别
Flouse · 2008-08-14 · via 博客园 - Flouse

  const char*, char const*, char*const的区别问题几乎是C++面试中每次都会有的题目。 这个知识易混点之前是看过了,今天做Linux上写GTK程序时又出现个Warning,发散一下又想到这个问题,于是翻起来重嚼一下。

事实上这个概念谁都有只是三种声明方式非常相似:

Bjarne在他的The C++ Programming Language里面给出过一个助记的方法:
把一个声明从右向左读。
char * const cp; ( * 读成 pointer to ) cp is a const pointer to char
const char * p; p is a pointer to const char;
char const * p; 同上因为C++里面没有const*的运算符,所以const只能属于前面的类型。

C++标准规定,const关键字放在类型或变量名之前等价的。
const int n=5; //same as below
int const m=10

结论:
char * const cp     : 定义一个指向字符的指针常数,即const指针
const char* p       : 定义一个指向字符常数的指针
char const* p       : 等同于const char* p

本文来自(网络): (www.91linux.com) 详细出处参考:

http://www.91linux.com/html/article/program/cpp/20080101/9442.html
略做修改,如侵犯版权,请与我联系。