更正错误

Correct the mistake

本文关键字:错误      更新时间:2023-10-16

为什么不编译此代码?

TextMem tmem, *fp = &tmem;
char *_res = new char[textbuf.mLength + 1];
tmem.Open(textbuf, TextStream::READ | TextStream::EOL_CRLF | TextStream::EOL_ORPHAN_CR, CP_UTF8);
tmem.Read(_res, textbuf.mLength);
tmem.Close();
char dbg[256];
sprintf(dbg, "mBuffer is %X, _res is %X", textbuf.mBuffer, _res);
MessageBox(NULL, dbg, "debug", MB_OK);
for (size_t i = 0; i < strlen(_res); i++)
_res[i] ^= 168;
sprintf(dbg, "mBuffer is %X, _res is %X", textbuf.mBuffer, _res);
MessageBox(NULL, dbg, "debug", MB_OK);
textbuf.mBuffer = _res;
textbuf.mLength = _ind;
sprintf(dbg, "mBuffer is %X, _res is %X", textbuf.mBuffer, _res);
MessageBox(NULL, dbg, "debug", MB_OK);
tmem.Open(textbuf, TextStream::READ | TextStream::EOL_CRLF | TextStream::EOL_ORPHAN_CR, CP_UTF8);

编译器在"sprintf"中发现错误,我应该怎么做才能消除这个错误?

我使用 Microsoft Visual Studio 2010

我使用Visual Studio 2010 Microsoft

也许你应该用_sprintf替换sprintf因为你的编译器。
我在那里没有看到任何错误。