The following will only read until the next white space occurs, excluding it
fscanf (list_in, "%s", keywords);
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.
If I understand your question correctly, you could use a character class:
Of course, to avoid buffer overruns, you should always set a maximum length when reading strings with (f)scanf, as in:
Edit: If you want to include the trailing whitespace character in the string, you could read it separately into a
charvariable using a%cdirective, and either process it that way or append it to the string:(Of course, to be extra careful, you should also check the return value of
fscanfto make sure you didn’t, for example, hit the end of the input file.)