With int snprintf(char *str, size_t size, const char *format, ...);
I can write specific number of characters into str .
How can I read specific number of characters from a c-string ?
Regards
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.
You can pass a number in the format argument:
This reads up to 20 characters into the
buf.If you do not know how much data you are going to read at compile time, you can prepare the format string at runtime: