The following code crashes while executing _strset_s I have given 80 as length in _strset_s. What could be the problem?. I enabled run time stack frame checkb option /RTCs
char strToken[80];
_strset_s(strToken, 80, '\0' );
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The input to
_strset_shas to be null terminated according to MSDN. Since your string is not initialized to anything, it violates this invariant.The default “invalid parameter handler” is to crash, again from MSDN:
So I’d try Null terminating strToken first (or better yet do what Bo Persson suggests in his answer)