อาร์เรย์ของสตริงสามารถสร้างขึ้นใน C ++ โดยใช้คีย์เวิร์ดสตริง เรากำลังพูดถึงโปรแกรม C++ โดยใช้แนวทางนี้
อัลกอริทึม
Begin Initialize the elements of array by string keyword. And take string as input. Print the array. End.
โค้ดตัวอย่าง
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
string Fruit[3] = {"Grape", "Mango", "Orange"};
cout <<"The name of fruits are:"<< "\n";
for (int i = 0; i < 3; i++)
cout<< Fruit[i]<<",";
return 0;
} ผลลัพธ์
The name of fruits are: Grape, Mango, Orange