从其他线程复制TCHAR *字符串

时间:2017-05-09 17:10:17

标签: c multithreading printf tchar

我想将另一个线程的数据复制到struct和print。 _tpintf()不显示俄语字母corret。enter image description here

在concole我看到了这一点,但我希望看到“INTHREADтекстклиент1”。请解释为什么tchar不起作用?另外我注意到如果我使用_tcprintf,“клиент1”显示正确,但“текст”出错了

enter image description here

试图从另一个

复制数据的线程函数代码
static DWORD WINAPI StdinInfo(LPVOID param)
{
   struct msg msg;
   TCHAR buf[1280] = { 0 };
   parameters* p = (parameters*)param;

    while (TRUE)
    {

       _fgetts(buf, 1280, stdin);
       while (_tcslen(buf) > 0 && buf[_tcslen(buf) - 1] == TEXT('\n'))
            buf[_tcslen(buf) - 1] = TEXT('\0');

       buf[128] = TEXT('\0');
       if (!_tcscmp(buf, TEXT("stop")))
       {
            //printf("Terminating...\n");
            msg.isEmpty = 0;
            msg.type = STOP;
            _tcscpy(msg.message, buf);
            _tcscpy(msg.nickName, p->nickName);

            SendMessage(p, &msg);
            break;
       }
       else if (!_tcscmp(buf, TEXT("exit")))
       {
            msg.isEmpty = 0;
            msg.type = DISCONNECT;
            _tcscpy(msg.message, buf);
            _tcscpy(msg.nickName, p->nickName);
            SendMessage(p, &msg);
            break;
       }

       msg.isEmpty = 0;
       msg.type = MESSAGE;
       _tcscpy(msg.message, buf);
       _tcscpy(msg.nickName, p->nickName);

       _tprintf(TEXT(" IN TREAD %s %s\n"), msg.message, p->nickName);

       SendMessage(p, &msg);
   }

   return 0;
 }

0 个答案:

没有答案