[c++] Printing an array in C++?

Is there a way of printing arrays in C++?

I'm trying to make a function that reverses a user-input array and then prints it out. I tried Googling this problem and it seemed like C++ can't print arrays. That can't be true can it?

This question is related to c++ arrays printing reverse

The answer is


Just iterate over the elements. Like this:

for (int i = numElements - 1; i >= 0; i--) 
    cout << array[i];

Note: As Maxim Egorushkin pointed out, this could overflow. See his comment below for a better solution.


Similar questions with c++ tag:

Similar questions with arrays tag:

Similar questions with printing tag:

Similar questions with reverse tag: