String.Format vc++ 中的异常

Exception in String.Format vc++

CString serror;
sError.Format( _T("Order Id- %d :CPVAudit could not audit event name: Medication Administration, and event type: %s"), dParticipantId, sEventType);

此代码抛出访问冲突异常。变量 dParticipantId(double)、sEventType(CString) 正在填充正确的值,但这一行仍然抛出异常。

如果 dParticipantId 是双精度数,则您使用的是错误的 type specifier。改为尝试类似“%f”的内容。否则,使 dParticipantId 为整数。