I am stuck in a printf problem. I would appreciate if I can get some help here: In the below code, I can see the font family get displaced correctly in first printf(), but if I set it to variable, i only get an empty string. How can I put it in a variable and have the right values? I just don't want to type 'font.family().family().string().utf8().data()' everywhere?
I did this in the same method:
void myMethod() {
const char* fontFamily = font.family().family().string().utf8().data();
// get displayed correctly
printf ("drawText1 %s \n", font.family().family().string().utf8().data());
// get an empty string
printf ("drawText2 %s \n", fontFamily);
}
And the signature of 'data()' is
class CString {
public:
CString() { }
CString(const char*);
CString(const char*, unsigned length);
CString(CStringBuffer* buffer) : m_buffer(buffer) { }
static CString newUninitialized(size_t length, char*& characterBuffer);
const char* data() const;
//...
}
The signature of utf8() is
class String {
CString utf8() const;
}
Thank you.
data()
. On a side note, any reason not to usestd::string
/std::cout
? – Oestrone.data()
method. – Kitts