C++ and C use "pass by value" by default. That is, when you call Input(), the rectangle in the calling function is copied into the "Rect" parameter of the function. Your function makes modifications to the local rectangle, but they are lost when this function returns.
One approach is to pass the rectangle by reference. In C++, you would write:
void Input(SDL_Rect &Rect)
{
// ...
}
The ampersand by the parameter asks the compiler to not make a copy, but to instead allow you to manipulate the caller's value. You don't have to change the code in the function, that remains the same. You do have to update any function declarations you have written for this function though to match.
C does not allow pass by reference, but you can simulate it by passing a pointer to a value. You must remember that this pointer itself is passed by value though. You can also do this in C++, but see below for why it might not be a good idea.
It would look like this:
void Input(SDL_Rect *Rect)
{
SDL_Event Event;
while(SDL_PollEvent(&Event))
{
if(Event.type == SDL_KEYDOWN)
{
if(Key == SDLK_LEFT)
{
Rect->x--;
}
if(Key == SDLK_RIGHT)
{
Rect->x++;
}
}
if(Event.type == SDL_QUIT)
{
Exit();
}
}
}
Note the arrow syntax required to dereference the pointer to access the member variable.
However, the C function does introduce an interesting new problem, what happens if the caller accidentally or intentionally passes a NULL pointer to the function? A simple solution is to document that the function does not allow NULL parameters. A better solution is to do this, but also use the assert() macro to validate that the parameter is not null in Debug mode. Finally, we could make the function "NULL safe", by not attempting to write to the Rect pointer if it is NULL.
For these reasons, I would prefer the C++ solution if you have a choice. It requires a not-null value by contract, so you don't have to worry yourself about working with the case where the pointer might be null.