Serial Port programming Code

Construct a working C++ program in either Dev-C developer for implementing a serial port programming code. You need to access the data coming in the serial port (USB port) via Arduino, to your laptop/desktop, and log that data into a text file called Log.txt.
You must find when the port is active and hence open the file, write the incoming data and
finally close it.
Check again for incoming data and re-open the file, to append new data.

For the Arduino, the following code is given, you have to use this.

int x;
void setup()
{
Serial.begin(9600);
}
void loop()
{
x = 0;
for(int i=0;i<20;i++)
{
Serial.print(“The Value of the variable is =”);Serial.println(x);
x++;
delay(1000);
}
delay(500);
}

What is the problem? Serial port starts @ 9600 baud and sending some data over serial port.

Consult your library specs, there should be some complementary interface like Serial.scan() or Serial.get(). Use it to read data. If you face a problem, please ask it.

//