Send and receive data through serial port In linux

I want to be able to detect every serial port device connected to the computer, and I want to be able to connect to the device that has the last serial pot number. I am a noob with c/c++ and I don't know where to start.
Can someone please give me an example on how to use serial ports and read/write to them in linux?
Thanks.
On Linux, and UNIX, most devices can be thought of as files, and as such, you can use the very basic, open(), read(), write(), close() functions available with any distribution. The name of the device is a little trickier. Here are some links:

https://wiki.archlinux.org/index.php/persistent_block_device_naming

http://en.wikipedia.org/wiki/Device_file

http://www.linuxquestions.org/questions/linux-general-1/how-could-i-find-my-device-name-6435/
Topic archived. No new replies allowed.