Ok, so by reading this question I've understood what \b
and \n
do exactly. I still don't know how to do the following:
I need to print all elements of an array separated by a space, then do some operation on that array and print another set of all elements from the array, a number of times, with each set separated by a newline. Something like this:
x[0] x[1] x[2] x[n]
x[0] x[1] x[2] x[n]
x[0] x[1] x[2] x[n]
(etc.)
This is my code:
std::printf("%f ",t);
for(int i=0;i<N;i++) {
std::printf("%f ", x[i]);
}
std::printf("\b\n");
However this leaves a trailing space at the end of each line. How can I make the output be "x[0] x[1] x[n]\nx[0] x[1] x[n]\n(...)"
instead of "x[0] x[1] x[n] \nx[0] x[1] x[n] \n(...)"
?