Trying to use snprintf but -QT- Qt isn't recognizing the function. I've included <stdio.h> but I'm using namespace std; due to using vectors. Any help here would be appreciated, thanks.
Moved to C++ gurus, as this isn't Qt-related at all.
snprintf is not a function of Qt, and also not of the STL (namespace std).
Which platform and which compiler tool chain are you using?
I found this page, which describes that there are versions of printf in std namespace (include cstdio) but I've never seen that before.
As I know the snprintf is conform only to C99 and C++11, so you have to use THAT compiler. GNU C++ 4.7 or later version is required to this.
There is qsnprintf(), a portable version of snprintf(); the "correct" way of doing such things however is using QString::sprintf().
[quote author="Lukas Geyer" date="1331209027"]There is qsnprintf(), a portable version of snprintf(); the "correct" way of doing such things however is using QString::sprintf().[/quote]
Hm... According to this site:
"Warning: We do not recommend using QString::sprintf() in new Qt code."
snprintf is a buffer_overrun_safe function, this is relatively new thing in the C/C++ world, so it can be used only under the newest C and C++ compilers.
Actually, I've found very little use to use any of the printf-related functions in Qt, as there are native QString methods for formatting and manipulating string contents appropriately. Depending on what you'd like to use snprintf() for, there is most likely a native Qt solution available through QString that would be more appropriate.
Thanks for the help. Can't say I've solved my problem, but to do that I'll be posting a new thread in the Qt Dev forum as the issue is related to the pixmap's loadFromData method.