What is the simplest way to read a full line in a C console program The text entered might have a variable length and we can’t make any assumption about its content.
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 need dynamic memory management, and use the
fgetsfunction to read your line. However, there seems to be no way to see how many characters it read. So you usefgetc():Warning: Never use
gets()! It does not do bounds checking and can overflow your buffer.