Hello everyone,
I have a function that gets the Message of the Day from the server, then prints it to the screen. The problem is I can only get the first line to print...
std::ifstream F("motd");
if (F.is_open())
{
std::string S;
std::getline(F, S);
if (! S.empty())
{
dbSetTextToNormal();
dbText (box_x + 18, box_y + 30, (char*)S.c_str());
}
}
To be honest, someone was kind enough to help me with that, and I do not fully understand how it works, so I tried my own:
string line;
ifstream motd ("motd");
if (motd.is_open())
{
while (! motd.eof() )
{
getline (motd,line);
dbSetTextToNormal();
sprintf(buffer, line.c_str());
dbText (box_x + 18, box_y + 30, buffer);
}
motd.close();
}
This prints all the lines, but all at once. So my question is, how do I change the state of dbText() every time a new line is encountered? I want it to do something like this:
//1st line
dbText (box_x + 18, box_y + 30, buffer);
//2nd line
dbText (box_x + 18, box_y + 42, buffer);
//3rd line
dbText (box_x + 18, box_y + 54, buffer);
//ect...