wirte a function for counting a linked list length

I know it's very simple but not easy.  I decieded that I write it by hand. its similar to strLen funtion
Maybe i am a dummy.
I use C.
version 1
int Count(char *s){
   int n=0;
    while(*s){
        n++;
        s++;
    }//while
    return n;
}//Count

version 2
int Count(char *s){
    int n=0;
    for(;*s;s++)
    n++;
    return n;
}

ok, done.....if you feel that it's not good, please post your smart code...thanks a lot.

posted @ 2007-09-18 20:05  HonestMan  阅读(163)  评论(0)    收藏  举报