String length using pointers

后端 未结 3 523
轮回少年
轮回少年 2021-01-29 12:54

I was looking up some code tricks. I found one that I get the basics but I don\'t understand why it exits. It has to do with a string pointer in a while loop. Usually I don\'

3条回答
  •  一个人的身影
    2021-01-29 13:57

    A string is an arrary of chars, of which the very last one is the terminating character - \0. The evaluation of while checks every char starting at position indcitated by pointer s, then shifting it to the next char (next array entry) by adding c to the start address. Once \0 - the terminating character - is reached the loop breaks.

提交回复
热议问题