Works.. A bit . but thanks.
No, it works *period*
You don't believe me ? Then make a small test example doing exactly as showed and you'll be able to see for yourself.
Just a friendly warning: Never ever directly implement a solution that is given to you if you do not know what you are doing. Instead, make a small test project that allows you to explore the given solution so that you are able to understand. If you have a couple of hundreds or even thousands lines of code then doing such things might be perfectly ok but, you are screwing yourself in case your code is running into tens of thousands lines of code and you do not have a clue anymore what you changed to implement such a provided solution made by someone else.
Of course, a proper version control would be able to help with that but, i have the vague notion you do not use that atm.
In game, it now tells 90 frames per second.. And after 5 seconds of playing, frames per second are 125.
That is because you are using multiple render-loops inside your code. For every render-loop you would have to calculate the ticks and apply as i wrote.
However, the solution as presented will only slow down on faster machines. It will do nothing for you in case your rendering loops take longer then those 16 ticks. In that case it will simply ignore and will not call the delay.
It is not very accurate which is why i named it a poor man's solution. If you want more precision then use high precision timers.
Furthermore, if you 'take over' your render-loop with a inner loop and bound things to that inner-loop then the calculation will also fail to do its job properly. You would have to account for that manually.
But, it does not matter if all you care for is to prevent the actual game-play to 'over speed' on faster machines. Simply apply the calculation to that render-loop only.
You also asked about vsync. That is not the holy grail. Note that different monitors, GPU's and video modes all have their own (different) refresh rates. You cannot assume anything about them, let alone sync your game with it as the speed differences will still be present if you rely on SDL's vsync option only.
What vsync option is very good for, is to prevent tearing.