CnComm使用有关问题

CnComm使用问题
在使用Cncomm时候
写入的时候:int i;
  //DWORD dwPara = PURGE_TXABORT | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_RXCLEAR ;
  char str[]="this is a test!";
  i =sizeof(str);
  Memo1->Lines->Add(AnsiString(str));
  if(!Com_.IsOpen())
  {
  ShowLog("COM is not open!");
  Com_.Open(ComboBox1->ItemIndex+1,L_Rate[ComboBox2->ItemIndex+1]);
  }
  else
  //Com_.Purge(dwPara);
  //Com_.ClearError();
  Com_.Write(str,i);

}
写入的数据为:this is a test!




接受的时候:DWORD Rtime=10;
  char buff[1024];
  //Com_.ClearError();
  Com_.Read(buff,1024,10);
  ShowLog(buff);

显示内容除了显示:this is a test!后面还有X?


请问X?是怎么回事,谁知道啊,请教学习!

------解决方案--------------------
要设终止符,X是乱码!!
------解决方案--------------------
是的,需要终止符。
确定一下Read函数读回来多少个字节,比如读回N个字节,然后再加一句:
buff[N] = 0x0;
就行了。