Hi,
In the program below, in the cout statement I want to understand what the code in the (ptr –arr) is doing. I understand ptr is the result of the find algorithm but I don’t know what the –arr does. If you can explain that to me I would appreciate it. I’m sure it is something simple but I don’t remember nor can find it.
Thanks!!
Shanna
// Finds the first object with a specified value
#include <iostream>
#include <algorithm>
using namespace std;
int arr[] = {11, 22, 33, 44, 55, 66, 77, 88};
int main()
{
int *ptr;
ptr = find(arr, arr+8, 33);
cout << "First object with value 33 found at offset " << (ptr -arr) << endl;
system("pause");
return 0;
}