demo-strings-arrays - for(int i = 0 i< length i go...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Example program: strings and arrays #include <iostream> #include <string> using namespace std; void PrintLengthsOfStrings(string words[], int length) // PRE: .length-1]) // POST: The lengths of words[0. .length-1] have been displayed on screen, // one per line
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { for(int i = 0; i < length; i++) // go through all elements of the array { cout << words[i].length() << endl; } } int main() { string demo[4]; // demonstration array demo[0] = "This"; demo[1] = "is"; demo[2] = "a"; demo[3] = "test."; PrintLengthsOfStrings(demo, 4); return 0; }...
View Full Document

Ask a homework question - tutors are online