index and element in array c++ code example
Example 1: how to index a array in cpp
int foo [5];
Example 2: how to get the index of an item in a array in c++
#include <iostream>
using namespace std;
int main() {
int array = {1, 2, 3, 4, 5};
for (int i = 0; i < sizeof(array)/sizeof(array[0]); i++) {
if (array[i] == 5) {
cout << i;
}
}
return 0;
}