int _tmain(int argc, _TCHAR* argv[]) { Communication comm; comm.AttachBRHandler(&MyHandler); comm.AttachBCHandler(&MyBaudHandler); unsigned int error; if(!comm.Connect(L"COM4", 115200, error)) { printf("%s", "Connection failed!\r\n"); } char answer[BUFFER_SIZE]; bool result = true; while(result) { scanf_s("%49s", answer, BUFFER_SIZE); //negated scanset option of scanf if(!strcmp("exit", answer)) { result = false; } else { if(!comm.Write(answer, strlen(answer))) printf("write failed\r\n"); } } return 0; }