demo-strings-arrays - { for(int i = 0; i <...

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 &lt; length; i++) // go through all elements of the array { cout &lt;&lt; words[i].length() &lt;&lt; endl; } } int main() { string demo[4]; // demonstration array demo[0] = &quot;This&quot;; demo[1] = &quot;is&quot;; demo[2] = &quot;a&quot;; demo[3] = &quot;test.&quot;; PrintLengthsOfStrings(demo, 4); return 0; }...
View Full Document

Ask a homework question - tutors are online