This is not natively supported in C/C++. Unless you're using a cross-platform library, the program will have to use platform-specific API calls to accomplish this. On *nix, I believe a serial port is treated similar to a file and you can open and write to it using the same calls as you would to read/write to a file.