I am learning C++ by myself through Udemy courses, and now thanks to some good advice I'm using a book "C++ Primer".
I will show you one of my codes. Please give me any advice on my route to programming, and why it does not work. It does not show the values in reversed manner using pointers.
#include <iostream>
using namespace std;
using std::cin;
using std::cout;
using std::endl;
void reverse_array (int *arr, int size)
{
int *start = arr;
int *end = arr + size -1;
while (start < end)
{
int temp = *start;
*start = *end;
*end = temp;
start ++;
end --;
}
}
int main ()
{
int arr [] {1,2,3,4,5,6,7};
int size = sizeof(arr)/ sizeof(arr[0]);
reverse_array (arr,size);
cout << reverse_array << endl;
}
cout << reverse_array << endl;Printing an array in C++? Also, you should print the array, not the function.int main () {at the start of the program.int size = sizeof(arr)/ sizeof(arr[0]);toauto size{ std::size(arr) };void reverse_array (int *arr, int size)returns nothing, so even once you get the call sorted out, still can't print the result.