+ 2

To enter an array of strings and print them again in cpp

strings in cpp

28th May 2018, 1:40 PM
Nakul Gopal
Nakul Gopal - avatar
2 Réponses
+ 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"; }
28th May 2018, 8:30 PM
MUHAMMAD ABDULLAH
MUHAMMAD ABDULLAH - avatar
+ 1
what if I want to enter string at console(output) screen
29th May 2018, 2:59 AM
Nakul Gopal
Nakul Gopal - avatar