Hi,
Either your compiler should have an option to specify the port like COM1/COM2 to be used or you have to write your own prinf() and getc() functions.
In order to use the functions printf, scanf, etc., usually you have to change the functions putchar and getchar to suit the UART (or IO devices) you want to use. I suggest you to read the user manual of your compiler.