#include#include int main() { std::array arr = {1, 2, 3, 4, 5}; int* ptr = arr.data(); for (int i = 0; i < arr.size(); ++i) { std::cout << *(ptr + i) << " "; } return 0; }
#includeIn this example, we create a character array `str` and initialize it with the string "Hello, world!". We then use the `strstr()` function from the `#include int main() { char str[] = "Hello, world!"; char* ptr = std::strstr(str, ", ") + 2; ptrdiff_t diff = ptr - str; std::cout << "Data from position " << diff << " is \"" << ptr << "\"" << std::endl; return 0; }