+ 2
How to print array in C+++
I have made this program Plz update it as necessary https://code.sololearn.com/c8tHfSCY614h/?ref=app https://code.sololearn.com/c8tHfSCY614h/?ref=app https://code.sololearn.com/c8tHfSCY614h/?ref=app
2 ответов
+ 13
Unfortunately, loops and user input won't work well together, for Code Playground.
+ 1
#include <algorithm> 
...
for_each(array.begin(), array.end(), 
    [](int i){ //int is here the type of the array's elements
        cout<<i<<' ';
    });
cout<<endl;
PS : creating a static array of size defined at runtime (not constant) is forbidden, you should do :
int * array = new int[arraySize];
...
delete array;
i <= arraySize will overflow, change it for <



