开发者

debug assertion failed using sprintf in c++

开发者 https://www.devze.com 2023-03-25 21:40 出处:网络
I keep getting the \"debug assertion failed\" error when i debug my code It seems to fail at the sprintf line in the function below:

I keep getting the "debug assertion failed" error when i debug my code

It seems to fail at the sprintf line in the function below:

void GetReference(int side)
{   
    for (int j=0; j<exposeNumber; j++)
    {
        image = cvQueryFrame(capture); // get the fir开发者_StackOverflow社区st frame of video

        sprintf(fileName, "RefImage%i", (side*exposeNumber + j));

        cvSaveImage(fileName, image);

        wait(200);

    }
}

"exposeNumber" is equal to 5 and "side" can either be 0 or 1

Cheers Chris


fileName MUST be big enough. And a char*. And not NULL. For example:

char fileName[1024];

or

char* fileName = new char[ 1024 ];
//..
delete[] fileName;

Or something smaller here. As I see, I guess 32 or 64 would be big enough.

I'm pretty sure the assertion fails because of NULL (or 0, which is the same here) pointer (fileName)

0

精彩评论

暂无评论...
验证码 换一张
取 消