I have made the new function putchar for redirect the output to LCD already. But by default, I also want to use this as output to serial port on the same program. I do not understand how to use both output function in parallel or other way to switch between each other. Please tell me if possible. With my thanks.
That's ANSI 'C' for you! In all fairness, ANSI C has nothing to do with this. What we're seeing here is a direct consequence of a design decision made by Keil: they decided to support printf(), but not fprintf() and fopen(), which would be the brutally obvious way a job like this would be done in actual ANSI C. I.e. the code at hand should be writable like this:
FILE *lcdout = fopen("mylcd_pseudofile", "w"); fprintf(lcdout, "this goes to the screen"); FILE *serialout = fopen("serial_pseudofile", "w"); printf("this goes to default output device");