What is the C equivalent to the C++ cin statement? Also may I see the syntax on it?
What is the C equivalent to the C++ cin statement? Also may I see
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.
cinis not a statement, it’s a variable that refers to the standard input stream. So the closest match in C is actuallystdin.If you have a C++ statement like:
a similar thing in C would be the use of any of a wide variety of input functions:
See an earlier answer I gave to a question today on one way to do line input and parsing safely. It’s basically inputting a line with
fgets(taking advantage of its buffer overflow protection) and then usingsscanfto safely scan the line.Things like
gets()and certain variations ofscanf()(like unbounded strings) should be avoided like the plague since they’re easily susceptible to buffer over-runs. They’re fine for playing around with but the sooner you learn to avoid them, the more robust your code will be.