Firstly, I don't think this is suitable for the beginner forum as SDL involves classes and stuff which aren't necessarily beginner friendly. (At least, not to a beginner who can't work a function let alone a pointer anyway...).
I'm having a bit of a brain seizure while going through LazyFoo's tuts and probably jumped ahead a little. After all, I was more keen on getting a blue box moving than focusing on the lessons. >_> *may have been the reason I didn't hit it off with university so well*. Well, now I have the blue box moving.
This moves my character just fine, but I think I might get RSI if I have to keep tapping the left button..... would keystates solve my dilemma or is there a better way to code it instead?
Just for a whacky crazy thing, I tried a while loop instead of if. It didn't have the intended consequences...*crashed my computer due to overheating*.
Keystates would do what you want however I normally use the same style you are using however make it change the players velocity not the position. You are going to have to work with player velocity sooner or later anyway, but it's your call there.
If you change it by velocity then somewhere else in the code you would have a move function that would look something like this (and you would call it every frame).
1 2 3 4 5
void Move()
{
x += xVel;
y += yVel;
}
I believe LazyFoo does everything in this style in his tutorials too (which I do recommend you read through carefully sooner or later just because they are very well done.)