I saw some C while loop with predicate as while(*ptr), and ptr is usually of char * type, how does this work? Does this mean “while()” will also accept values other than 1 or 0 as predicates?
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.
In C, any non-zero value is considered “true”, so
while (*ptr)will loop as long as*ptris non-zero.