Do you want to:
RECT Rect; GetWindowRect(consoleWindow, &Rect); cout << Rect.top <<endl;
I would say that you are a C # guy because you tried to use types and API calls without understanding pointers. LPRECT is a derived type that says it is a pointer to a RECT . Having a variable of this type, you pointed to a pointer to nothing, to an invalid memory address (the pointer variable remains uninitialized). Your code is expected to crash the application.
Instead, you need to save the RECT variable and pass a pointer to it so that it is initialized / registered by the API.
source share