P
Philip Parker
is there any way to track back x number of characters after its been cout 'd
, and overwrite part of it ?
, and overwrite part of it ?
Philip Parker said:is there any way to track back x number of characters after its been cout 'd
, and overwrite part of it ?
'd
No, at least not in standard C++.. You should probably forget about cout and
instead use whatever console functions your platform provides. This is
definitely possible, just not in standard C++.
Jan Engelhardt said:Maybe using a new class which inherits from cout?
int ::cout(char *s) {
real_cout << s;
return strlen(s);
}
Philip said:ah well. was hoping to have some sort of auto-filling progress indicator.
guess i`ll just have to do without , or learn win32 programming heh
Jacques Labuschagne said:Philip said:ah well. was hoping to have some sort of auto-filling progress indicator.
guess i`ll just have to do without , or learn win32 programming heh
Well why didn't you say so? You don't need to seek through stdout to do
that, you just need to make it *look* like you're changing the output.
Experiment with the backspace character (\b)... You can do things like
// print [ ] complete
cout << "[ ] complete";
// print [XX ] complete
cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bX ] complete";
// print [XXX ] complete
cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bX ] complete";
...
// print [XXXXXXXXXX] complete
cout << "\b\b\b\b\b\b\b\b\b\b\bX] complete";
Jacques.
Andre said:You can also use \r to get back to the left margin and overwrite
everything.
ah well. was hoping to have some sort of auto-filling progress indicator.
guess i`ll just have to do without , or learn win32 programming heh
Philip Parker said:is there any way to track back x number of characters after its been cout 'd
, and overwrite part of it ?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.