+ 4

Array: What is error?

#include <iostream> using namespace std; void printArray(int arr[]) { int a=(end(arr)-begin(arr)); //or a=sizeof(arr)/sizeof(arr[0]; for(int x=0; x <a ; x++) { cout <<arr[x]<< endl; } } int main() { int myArr[]= {42, 33, 88,9,77,66}; printArray(myArr); }

27th Oct 2016, 6:38 AM
Nima J.
Nima J. - avatar
1 ответ
+ 3
template <size_t N> void printArray(int (&arr)[N]) { for(int x=0; x < N; x++) { cout << arr[x] << endl; } }
27th Oct 2016, 9:15 AM
Zen
Zen - avatar