Is there a way to use the C sprintf() function without it adding a ‘\0’ character at the end of its output? I need to write formatted text in the middle of a fixed width string.
Share
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.
There is no way to tell
sprintf()not to write a trailing null. What you can do is usesprintf()to write to a temporary string, and then something likestrncpy()to copy only the bytes that you want.