c++ - Carriage Return Multiple Lines -
i'm working on console based fps/clock display debugging allegro game i'm working on, , i've been trying figure out how console output change without having stick arbitrary system("cls") @ top of game loop.
right have...
while(game.running()) { std::cout << "\r" << "fps: " << getframerate() << "\n" << "\r" << "time: " << gettime(); // other game loop things... }
what i'm going this, line rewritten each time.
fps: ___ time: ___
(where ___ whatever current value is)
but when run get...
fps: ___ fps: ___ fps: ___ time: ___
↑ goes on , on... fills screen fps:__ , single time:__ @ bottom without overwriting.
'\r' has confounded me, , haven't found useful on google. appreciated.
how using putchar(int) ? putchar(0x08) backspace or so.
i'm not sure, problem cr(0x0d carriage return) , lf(0x0a line feed) doesn't work expected. maybe because std::cout class flush standard out ( in case terminal ) after several getframerate() call.
Comments
Post a Comment