1.C++端
int EndRecognition(char* result)
{
int errcode;
char m_Result[1024];
memset(m_Result,0,1024);
if (errcode = sr_stop_listening(&asr, m_Result)) {
printf("stop listening failed %d\n", errcode);
}
memcpy(result, m_Result, sizeof(m_Result));
return errcode;
}
2.C#端
byte[] s = new byte[1024];
int t = EndRecognition(ref s[0]);//用字节数组接收动态库传过来的字符串
string strGet = System.Text.Encoding.Default.GetString(s, 0, s.Length); //将字节数组转换为字符串
textBox.Text = strGet.Replace('\0',' ').Trim();