+ 2
To enter an array of strings and print them again in cpp
strings in cpp
2 odpowiedzi
+ 1
First of all, you must declare an array of strings and initialize it. Then, use for loop for printing array elements to your computer screen. as Follows:
#include<iostream>
#include<string>
using namespace std;
int main()
{
// Initialize String Array
string animal[6] = {"Cat", "Dog", "Lion", "Snake", "Frog", "Bear"};
// Print Strings
for (int i = 0; i < 6; i++)
cout << animal[i] << "\n";
}
+ 1
what if I want to enter string at console(output) screen