欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

c ++查找字符串_C ++数组| 查找输出程序| 套装5

发布时间:2023/12/1 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 c ++查找字符串_C ++数组| 查找输出程序| 套装5 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

c ++查找字符串

Program 1:

程序1:

#include <iostream> 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 <iostream> 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<<STR[2]+1;

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++ Arrays | Find output programs | Set 1

    C ++数组| 查找输出程序| 套装1

  • C++ Arrays | Find output programs | Set 2

    C ++数组| 查找输出程序| 套装2

  • C++ Arrays | Find output programs | Set 3

    C ++数组| 查找输出程序| 套装3

  • C++ Arrays | Find output programs | Set 4

    C ++数组| 查找输出程序| 套装4

  • C++ Looping | Find output programs | Set 1

    C ++循环| 查找输出程序| 套装1

  • C++ Looping | Find output programs | Set 2

    C ++循环| 查找输出程序| 套装2

  • C++ Looping | Find output programs | Set 3

    C ++循环| 查找输出程序| 套装3

  • C++ Looping | Find output programs | Set 4

    C ++循环| 查找输出程序| 套装4

  • C++ Looping | Find output programs | Set 5

    C ++循环| 查找输出程序| 套装5

  • C++ Default Argument | Find output programs | Set 1

    C ++默认参数| 查找输出程序| 套装1

  • C++ Default Argument | Find output programs | Set 2

    C ++默认参数| 查找输出程序| 套装2

  • C++ Class and Objects | Find output programs | Set 1

    C ++类和对象| 查找输出程序| 套装1

  • C++ Class and Objects | Find output programs | Set 2

    C ++类和对象| 查找输出程序| 套装2

  • C++ Class and Objects | Find output programs | Set 3

    C ++类和对象| 查找输出程序| 套装3

  • C++ Class and Objects | Find output programs | Set 4

    C ++类和对象| 查找输出程序| 套装4

  • C++ Class and Objects | Find output programs | Set 5

    C ++类和对象| 查找输出程序| 套装5

翻译自: https://www.includehelp.com/cpp-tutorial/arrays-find-output-programs-set-5.aspx

c ++查找字符串

总结

以上是生活随笔为你收集整理的c ++查找字符串_C ++数组| 查找输出程序| 套装5的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。