how to loop back for this code ?
why the following code cant loop for contineously reading the data and give output??
please help
thank you!!
Code:
#include <windows.h>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
DCB dcb;
HANDLE hComm;
char buff[9];
DWORD size;
hComm = CreateFile(
"COM1",
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0
);
dcb.BaudRate = 4800;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
if( hComm == INVALID_HANDLE_VALUE ) exit( 1 );
while(true)
{
ReadFile(hComm, buff, 8, &size, NULL);
cout << buff << endl;
getchar();
}
return 0;
}