Z.K.
2008-04-20 21:09:04 UTC
I was trying to convert the sprintf statement to sprintf_s, but though
it compiles, it gives me an exception everytime when it reaches the
sprintf_s statement and I am not really sure why. My knowledge of
unicode and these new functions in VS 2005 are still new to me though I
thought this would work since the only difference was a size requirement.
const int BUFFSIZE = 128;
char buffer2[BUFFSIZE];
lpstrEditcmd = &buffer2[0];
//sprintf(lpstrEditcmd,"%s\\edit.com",lpstrSysDir);
sprintf_s(lpstrEditcmd,sizeof(lpstrEditcmd),"%s\\edit.com",lpstrSysDir);
Of course if I just arbitrarily put in a size such as 128, then it gets
passed that statement. I have used this same code in Visual 2003
without the modifications and it worked fine.
Z.K.
it compiles, it gives me an exception everytime when it reaches the
sprintf_s statement and I am not really sure why. My knowledge of
unicode and these new functions in VS 2005 are still new to me though I
thought this would work since the only difference was a size requirement.
const int BUFFSIZE = 128;
char buffer2[BUFFSIZE];
lpstrEditcmd = &buffer2[0];
//sprintf(lpstrEditcmd,"%s\\edit.com",lpstrSysDir);
sprintf_s(lpstrEditcmd,sizeof(lpstrEditcmd),"%s\\edit.com",lpstrSysDir);
Of course if I just arbitrarily put in a size such as 128, then it gets
passed that statement. I have used this same code in Visual 2003
without the modifications and it worked fine.
Z.K.