for example:
-----
float Spinner::getValueFromText(void) const
{
// handle empty case
if (d_editbox->getText().empty())
{
return 0.0f;
}
int res, tmp;
uint utmp;
float val;
switch (d_inputMode)
{
case FloatingPoint:
res = sprintf_s(d_editbox->getText().c_str(), d_editbox->getText().max_size(), "%f", &val);
-----
writes to c_str(). if i replace sprintf with sprintf_s, what should i use as size? d_editbox->getText().max_size() ?
(i'am "porting" the 0.41 source to vc8)
best regards,
thomas
writing to c_str() - secure?
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: writing to c_str() - secure?
Unfortunately you can't write to the buffer returned from CEGUI::String::c_str - it's const. And also, it's not the actual buffer where the string data is stored; so even if you could write to it, the actual string content would not be updated.
The 'best' way to achieve the desired result using these types of functions is to use a temporary char array, then assign this to the CEGUI::String afterwards.
HTH
CE.
The 'best' way to achieve the desired result using these types of functions is to use a temporary char array, then assign this to the CEGUI::String afterwards.
HTH
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “CEGUI Library Development Discussion”
Who is online
Users browsing this forum: No registered users and 5 guests