How can char* be a condition in for loop?

Posted by Jackie on Stack Overflow See other posts from Stack Overflow or by Jackie
Published on 2010-04-16T15:56:27Z Indexed on 2010/04/16 16:03 UTC
Read the original article Hit count: 268

Filed under:
|

In a book I am reading there is a piece of code :

string x;
size_t h=0;
for(const char* s=x.ctr();*s;++s)
    h=(h*17)^*s;

Regarding this code, I have two questions:

  1. how can *s be a condition? what does it mean?

  2. what does "h=(h*17)^*s" mean?

Thanks for help!

© Stack Overflow or respective owner

Related posts about c++

Related posts about c