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:
輸出:
OExplanation:
說明:
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:
輸出:
AMExplanation:
說明:
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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux下g++和gcc_Linux中
- 下一篇: 地下城堡3魂之诗奥西里斯之果怎么获得