I figure using fgets is the best option, but apparently it takes input from stdin? How do I generate a random number using rand(), and store it?
I figure using fgets is the best option, but apparently it takes input from
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.
You can use
sprintf():A more robust option is to use
snprintf()if your runtime library offers it:Using
snprintf()in this way ensures that the resulting string will not overflow the bounds ofbuf.