in vc++, Debug assertion failed Expression: length < sizeInTChars
-
Hi, Header.h --------
using namespace std;
class defaultlog
{
public:
static unsigned int& CmdNumber()
{
static unsigned int cmd_Number(0);
return cmdNumbers;
}
static unsigned int& ErrorCount()
{
static unsigned int err_count(0);
return errcounts;
}
};and my main.cpp
char sErrNumb[7]; char scmdNumb[5]; void ClearLog() { _itoa_s(logger::CmdNumber()++,scmdNumb,10); _itoa_s(logger::ErrCount(),sErrNumb,10); fprintf(fileName," %s",sErrNumb);
} when the control reaches the first _itoa_s I get the DEBUG ASSERTION FAILED (refer subject) How to solve this problem. I pass the scmdNumb to a file using fprintf
-
Hi, Header.h --------
using namespace std;
class defaultlog
{
public:
static unsigned int& CmdNumber()
{
static unsigned int cmd_Number(0);
return cmdNumbers;
}
static unsigned int& ErrorCount()
{
static unsigned int err_count(0);
return errcounts;
}
};and my main.cpp
char sErrNumb[7]; char scmdNumb[5]; void ClearLog() { _itoa_s(logger::CmdNumber()++,scmdNumb,10); _itoa_s(logger::ErrCount(),sErrNumb,10); fprintf(fileName," %s",sErrNumb);
} when the control reaches the first _itoa_s I get the DEBUG ASSERTION FAILED (refer subject) How to solve this problem. I pass the scmdNumb to a file using fprintf
-
That code will not even compile. Also, this is not a Visual Studio issue, please use the C++ forum.
Veni, vidi, abiit domum
-
Thanks Richard, but this code is in VC++ and it did work.... The class "defaultlog" was executed successfully in a subfunction defined under test.cpp Then once the control branches to main.cpp, i get this error.