Alternative zu wsprintf
-
Hallo an alle!
Wie kann ich schnell anstatt
int len = wsprintf(string, "%d", num);
implementieren um nicht windows einlinken zu müssen?? Also eine Zahl in einen Text schieben.
Danke im Voraus
-
int sprintf(char *buffer, const char *format [, argument] ...); int swprintf(wchar_t *buffer, const wchar_t *format [, argument] ...);
aus dem Header cstdio.
oder du bentutzt nen std::stringstream aus sstream Header.
-
#include <iostream> #include <sstream> #include <string> int main() { std::string text1, text3; int zahl; text1 = "diese nummer: "; text3 = " erscheint nun als string im text"; zahl = 23; std::ostringstream sstr; sstr << zahl; std::string text2(sstr.str()); text1 += text2 + text3; std::cout << text1 << std::endl; }
-
asfsadfasdf schrieb:
Wie kann ich schnell anstatt
int len = wsprintf(string, "%d", num);
implementieren um nicht windows einlinken zu müssen??
Einfach swprintf nehmen.
Wie aber schon gesagt, nimmt man in C++ dafür stringstreams.