#include <iostream> // Print a single element (use in array version) template<typename T> void printArray(T const &e, std::ostream& out = std::cout ) { out << e; } // Print an (nested) array template<typename T1, size_t arrSize> void printArray(T1 const(& arr)[arrSize], std::ostream& out = std::cout ) { out << "["; if ( arrSize ) { const char* sep = ""; for (const auto& e : arr) { out << sep; printArray(e, out); sep = ", "; } } out << "]"; } int arr[5][5]; int main() { printArray( arr[0] ); std::cout << std::endl; printArray( arr ); }
Standard input is empty
[0, 0, 0, 0, 0] [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]