fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5. std::string words[2]; //make an array to hold our words
  6. words[0] = "Hello"; //set the first word (at index 0)
  7. words[1] = "World"; //set the second word (at index 1)
  8. int numWords = 2; //make sure we know the number of words!
  9.  
  10. //print each word on a new line using a loop
  11. for(int i = 0; i < numWords; ++i)
  12. {
  13. std::cout << words[i] << '\n';
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Hello
World