How to wait Arduino ready with ANY method?
Again, you're not waiting for the bootloader to complete before sending your text:

port.open(argv[1], std::fstream::in | std::fstream::out);
// Board resets and enters bootloader

port &lt;&lt; argv[2] &lt;&lt; endl;
// You send argv[2] to the bootloader

port &gt;&gt; answer;
// The bootloader doesn't understand what you sent so doesn't reply with anything


You must wait for the bootloader to complete before sending ANYTHING to the Arduino.

The two ways you can do that are:


Insert a sleep(3); immediately after opening the port to give the bootloader a chance to time out and start running your sketch, or
Provide an initial "I Am Ready" message from your sketch that your C++ program waits for before sending the text you want to send to elicit an answer.