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. 【bzoj4448】SCOI2015 情报传递

    树剖,可以相当于一个染色问题,以及询问先前节点的染色个数. 把第二种操作离线掉,然后用线段树模拟即可. #include<bits/stdc++.h> #define N 800010 # ...

  2. HDU 6188 Duizi and Shunzi 贪心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 题意:给了n个数,然后现在问我们最多构成多少个对子和顺子,其中对子是2个相同的牌,顺子是3个连续 ...

  3. centos7.4关闭防火前

    systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动firew ...

  4. FTP webReq.ContentType异常的处理

    FtpWebRequest webReq; webReq = (FtpWebRequest)FtpWebRequest.Create(new Uri(updateFileUrl)); FtpWebRe ...

  5. jQuery实现,动态自动定位弹窗。JS分页,Ajax请求

    工作中碰到一个问题,一个页面中碰到多个地方需要弹窗数据. 网上找了一圈,没有找到合适的,所以自己写了一个. 兼容IE7+,chrome.其它未测试. 需求:点击任意的输入框(也可其它元素,代码中有注释 ...

  6. http跟https的区别

    http: Hypertext transform protocol 超文本传输协议 是一个为了传输超媒体文档(比如html)的应用层协议 是为了web的浏览器跟web的server端的交流而设计的, ...

  7. 【JBPM4】创建流程实例

    示例代码: ProcessEngine processEngine = Configuration.getProcessEngine(); ExecutionService executionServ ...

  8. Lucene.Net无障碍学习和使用:搜索篇

    一.初步认识搜索 先从上一篇示例代码中我们摘录一段代码看看搜索的简单实现: private TopDocs Search(string keyword,string field) { TopDocs ...

  9. logrotate日志轮转

    1)基本介绍 适合应用服务日志,系统日志按天切割 如果没有日志轮转,日志文件会越来越大 将丢弃系统中最旧的日志文件,以节省空间 logrotate本身不是系统守护进程,它是通过计划任务crond每天执 ...

  10. ZOJ 3279-Ants(线段树)

    传送门:zoj 3279 Ants Ants Time Limit: 2 Seconds      Memory Limit: 32768 KB echo is a curious and cleve ...