Serial communication is a bit cumbersome, but
Serial library for C++ article will give you some insights of the used API and some details.
Important is to understand that the communication "takes time" up to some seconds and so your code needs to wait gentle for some answers. I have coded some 20 years ago some serial communication and ended with that "overlapped" stuff.
So be patient for good results. Good luck ;-)