The special relationship between arrays and pointers extends to C-style strings.Consider the following code:
char flower[10]="rose";
cout<<flower<<"s are red\n";
The name of an array is the address of ite first element,so flower in the cout statement is the address of the char element containing the character r.

The cout object assumes that the address of a char is the address of a string,so it prints the character at that address and then continues printing characters until it runs into the null character(\0).

In short,if you give cout the address of a character,it prints everything from that character to the first null character that follows it.

The crucial element here is not that flower is an array name but that flower acts as the address of a char.This implies that you can use a pointer-to-char variable as an argument to cout,also,because it,too,is the address of a char.Of course,that pointer should point to the beginning of a string.

Pointers and Strings的更多相关文章

  1. How to distinguish between strings in heap or literals?

    Question: I have a use case where I can get pointers of strings allocated either in memory or litera ...

  2. SQLite源程序分析之sqlite3.c

    /****************************************************************************** ** This file is an a ...

  3. 分享O'Reilly最新C语言指针数据

    1.推荐书名 Understanding.and.Using.C.Pointers.pdf 2. 本书目录 Table of Content Chapter 1. Introduction Chapt ...

  4. JavaScript 堆内存分析新工具 OneHeap

    OneHeap 关注于运行中的 JavaScript 内存信息的展示,用可视化的方式还原了 HeapGraph,有助于理解 v8 内存管理. 背景 JavaScript 运行过程中的大部分数据都保存在 ...

  5. 《Peering Inside the PE: A Tour of the Win32 Portable Executable File Format》阅读笔记二

    Common Sections The .text section is where all general-purpose code emitted by the compiler or assem ...

  6. PE Header and Export Table for Delphi

    Malware Analysis Tutorial 8: PE Header and Export Table 2. Background Information of PE HeaderAny bi ...

  7. Dr.memory

    Run Dr.memory on visual c++ 2013 Title: Dr. Memory Command: C:\Program Files (x86)\Dr. Memory\bin\dr ...

  8. getopt使用

    参考: http://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html http://en.wikipedia.org ...

  9. C++ - main()函数参数

    main()函数及其参数说明 main()函数主要形式: int main(void) int main(int argc, char *argv[]) = int main(int argc, ch ...

随机推荐

  1. [转载]循规蹈矩:快速读懂SQL执行计划的套路与工具

    作者介绍 梁敬彬,福富研究院副理事长.公司唯一四星级内训师,国内一线知名数据库专家,在数据库优化和培训领域有着丰富的经验.多次应邀担任国内外数据库大会的演讲嘉宾,在业界有着广泛的影响力.著有多本畅销书 ...

  2. gunicorn 启动无日志

    gunicorn -c gunicorn_info.py info:app 接手整理老项目,发现有个服务迁移后启动不了,也没报错信息 修改gunicorn_info.py里的daemon = not ...

  3. ES6 promise简单实现

    基本功能实现: function Promise(fn){ //需要一个成功时的回调 var doneCallback; //一个实例的方法,用来注册异步事件 this.then = function ...

  4. python_day2学习笔记

    基本数据类型 1.数字 int(整型) 在32位机器上,整数的位数为32位,取值范围为-2**31-2**31-1,即-2147483648-2147483647 在64位系统上,整数的位数为64位, ...

  5. linux命令(3):rpm命令

    查询当前环境是否已安装软件包,如下命令: [root@cloud ~]# rpm -qa | grep httpd httpd-2.4.6-31.el7.centos.1.x86_64 httpd-t ...

  6. 【Mac电脑】Jenkins的安装

    1.JDK自己下载安装喽, 2.下载Jenkins 下载路径:https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/2.121.1/jenki ...

  7. spawn-fcgi出错处理

    /usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9002 -C 25 -f /usr/local/nginx/cgibin/lzgFastCGI 添加 ...

  8. 将excel中的sheet1导入到sqlserver中

    原文地址:C#将Excel数据表导入SQL数据库的两种方法作者:windream 方式一: 实现在c#中可高效的将excel数据导入到sqlserver数据库中,很多人通过循环来拼接sql,这样做不但 ...

  9. 定位所用的class

    方案 为解决类冲突,我们可以使用下述的方案定位一个class所在的位置 ClassName. package cn.j2se.junit.classpath; import static org.ju ...

  10. 爬楼梯(LintCode)

    爬楼梯 假设你正在爬楼梯,需要n步你才能到达顶部.但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? 样例 比如n=3,中不同的方法 返回 3 用递归又超时了..于是又换了DP,dp并不熟 ...