How do I output the array?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
Tell me how to remove the array, only the part which initialized? For example, the length of the array 100,
and the user entered only 5 items. you should print only these 5 items and not the entire array.

an example of such code.
int main() { #include #include using namespace std; int main() { string str[200]; for (int i = 0; i < 200; ++i) { getline(cin, str); } //How to display for example only 5 strings??? }
by | 11 views

1 Answer

0 like 0 dislike
Add numberOfUserEnteredStrings counter, increase it everytime the user enters something.
When the output cycle do not to 200, and already to numberOfUserEnteredStrings.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
35,403 users