So im looking through some tutorials for SDL and i stumbled upon this piece of code, i more or less know what it is doing, but im just uncertain because some of the syntax is new, plus i find the precise answer online, could someone explain what each line is doing?:
1 2 3 4 5 6
std::stringstream timeText;
/*more code i decided to skip because it was unrelated*/
timeText.str( "" );
timeText << "Milliseconds since start time " << SDL_GetTicks() - startTime;
That clears the contents (not the state) of the stringstream.
timeText << "Milliseconds since start time " << SDL_GetTicks() - startTime;
This inserts the "Milliseconds since start time" into the stringstream, and then it inserts SDL_GetTicks() - startTime into it. You should be familiar with iostreams (std::cin, std::cout, etc). They are similar to stringstreams in that you insert/extract the content you want using operator<< (or operator>>), however a stringstream simply stores the value for usage, unlike std::cout, which displays the output.
I am awful at explaining things, so read up on stringstreams here.