Quote:Original post by Lith
so i thought that this:
text = stream.str();
was adding to it
There are two conceptual problems here.
1) This:
text.c_str() = "";
does nothing useful. The .c_str() member function returns a pointer, after all, so this is just taking the copy of the string's internal pointer and assigning it to point at an empty string. This has no effect on the text pointed at by the string.
This is deliberate: you are not supposed to be able to re-point the string's internal pointer. The string is responsible for keeping track of that pointer, not you. If you want to clear out the string, assign
to the string.
2) But even then, assigning to the string would have no effect on the
stream, because the string 'text' is, again, a
copy of the stream's internal string object.
Rip-off's code gets around this by re-creating the stream from scratch every time (via calling the function). Notice that he doesn't reset the contents of anything afterward; there is no need to, because the stream is thrown away, and the string can also be thrown away once you've passed its .c_str() to the rendering function.
Quote:the compiler is complaining about missing ; in my classes now
That's because there's a ; missing somewhere. Error messages include line numbers, which should point you to the right part of the code. You're supposed to be able, by now, to read code and figure out where simple things like this have gone wrong. This kind of problem-solving is more basic than doing stuff like rendering text with SDL, so you should make sure you can do it yourself first.