博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c ++查找字符串_C ++数组| 查找输出程序| 套装5
阅读量:2534 次
发布时间:2019-05-11

本文共 1204 字,大约阅读时间需要 4 分钟。

c ++查找字符串

Program 1:

程序1:

#include 
using namespace std;int main(){ char* STR[] = { "HELLO", "HIII", "RAM", "SHYAM", "MOHAN" }; cout << (*STR + 2)[2]; return 0;}

Output:

输出:

O

Explanation:

说明:

Here we create an array of pointers to store strings. Now, look at the cout statement,

在这里,我们创建一个指针数组来存储字符串。 现在,看看cout语句,

cout<<(*STR+2)[2];

The above statement will print the element of the 4th index of 1st string because pointer STR pointing the 1st string that is "HELLO" so the above statement will print 'O'.

上面的语句将打印第一个字符串的第4 索引的元素,因为指针STR指向“ HELLO”的 第一个字符串,因此,上面的语句将打印“ O”

Program 2:

程式2:

#include 
using namespace std;int main(){ char STR[5][8] = { "HELLO", "HIII", "RAM", "SHYAM", "MOHAN" }; cout << STR[2] + 1; return 0;}

Output:

输出:

AM

Explanation:

说明:

Here, we created a program two-dimensional array for strings. Now look the cout statement,

在这里,我们为字符串创建了一个程序二维数组。 现在看一下cout语句,

cout<

In the above statement, STR[2] is pointing to the 'R' in the string  "RAM" and we move pointer one position ahead then it will print "AM" on the console screen.

在上面的语句中, STR [2]指向字符串“ RAM”中“ R ,我们将指针向前移动一个位置,然后它将在控制台屏幕上打印“ AM”

Recommended posts

推荐的帖子

翻译自:

c ++查找字符串

转载地址:http://crxzd.baihongyu.com/

你可能感兴趣的文章
[T-ARA/筷子兄弟][Little Apple]
查看>>
编译Libgdiplus遇到的问题
查看>>
【NOIP 模拟赛】Evensgn 剪树枝 树形dp
查看>>
java学习笔记④MySql数据库--01/02 database table 数据的增删改
查看>>
两台电脑如何实现共享文件
查看>>
组合模式Composite
查看>>
程序员最想得到的十大证件,你最想得到哪个?
查看>>
我的第一篇CBBLOGS博客
查看>>
【MyBean调试笔记】接口的使用和清理
查看>>
07 js自定义函数
查看>>
jQueru中数据交换格式XML和JSON对比
查看>>
form表单序列化后的数据转json对象
查看>>
[PYTHON]一个简单的单元測试框架
查看>>
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>