I need to call a function from main. The side effect of the function is to print a new line char. Is there any way to remove that char?
The program looks like:
#include "header_file.h"
#include <stdio.h>
int main() {
for (int i=0; i<1e5; i++) {
int A = HEADER_SPACE::func_linebreak();
printf("\b");
}
printf("1234");
return 0;
}
I don't know if it is cout << endl;
or printf("\n");
in the func_linebreak()
function. I don't know if there is fflush(stdout);
inside it.
One thing for sure is that I always run the binary/exe file with output redirect: ./my_main.out >> outFile.txt
in Linux system.
This post does not work here.
It turns out that the most convenient way to remove the newline sign is to disable the printing from beginning. In my current application, fortunately, I'm able to do that.
My problem has been solved, but I won't delete this post since there might be cases when the source code is unavailable, and some one may still wants to achieve the same goal.