Answer the question
In order to leave comments, you need to log in
How to output a dynamic array in C++?
I'm getting this problem: C++ this range-based 'for' statement requires a suitable function and none was found .
What am I doing wrong?
void printArray(int *arr = {}) {
for (const auto &e : arr) {
cout << e << endl;
}
}
Answer the question
In order to leave comments, you need to log in
It is possible, if the length of the array is known, to change as follows:
void printArray(int *arr ,size_t size)
{//size-длина массива
for (size_t el=0;el<size;el++) {
cout << arr[el]<< endl;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question