开发者

debug assertion failed using sprintf in c++

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜