fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  6.  
  7. int *ptr = &array[4];
  8.  
  9. int i = ptr - array;
  10. std::cout<< i<< '\n';
  11.  
  12. return 0;
  13. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
4