int foo(int *A);
int main()
{
int* ptr = nullptr;
*ptr = foo(ptr); // Line X
return 0;
}
int foo(int *A)
{
A = new int[10];
return *A;
}
When I perform this line of code it gives me a write access error the moment it returns the function call to on line x. It states ptr
was nullptr
.
I don't understand what this means. I'm trying to dynamically create an array inside this function, return a pointer back to the main, and then modify the values inside.