C++ application send data on serial only when closed
<p>Using this guide/class (<a href="http://playground.arduino.cc/Interfacing/CPPWindows" rel="nofollow">http://playground.arduino.cc/Interfacing/CPPWindows</a>) I wrote a little application to send data on the serial port to an Arduino. (This will be added on a larger project later on)</p>

<pre><code>int _tmain(int argc, _TCHAR* argv[]) {

    Serial* SP = new Serial(argv[1]);

    char outcomingData[256];
    int dataLength = 255;
    int sendData;

    while (SP-&gt;IsConnected()) {

        strcpy_s(outcomingData, argv[2]);
        sendData = SP-&gt;WriteData(outcomingData, dataLength);
        printf("%s", outcomingData);

    }

    return 0;
}
</code></pre>

<p>The problem is that the data is sent only when I close the application or delete SP through the destructor. How can I fix this? Is there a workaround or another method that I can add to the class?</p>