I am new to C and C++. I have defined a static function which has a pointer 'ptr'. How can I access the pointer outside the function?
#include <iostream>
using namespace std;
static void accessArr(uint8_t arr[]);
int main()
{
uint8_t arr[] = {1,2,3,4,5};
accessArr(arr);
cout << *ptr <<endl;
return 0;
}
void accessArr(uint8_t arr[])
{
uint8_t *ptr = arr;
}
I am getting the below error for the above code. Please help in solving the error.
main.cpp:12:14: error: ‘ptr’ was not declared in this scope
cout << *ptr <<endl;
^~~