>>> So I am not in a console.
Okay, so forget cout and printf()! sprintf() is not the same, printf() write to the screen in a console, sprintf() write to a string.
What you could do is pop the strings up in a message box, but that will get really tedious if you have a lot of records. It might be worth trying just to see if you have anything remotely sensible in your variables. Just as an experiment, put this in your loop...
... and see if anything recognisable happens