+ 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); }
1 Resposta
+ 3
template <size_t N>
void printArray(int (&arr)[N]) {
for(int x=0; x < N; x++) {
cout << arr[x] << endl;
}
}