what does the - operator do with char *?

后端 未结 4 2046
忘了有多久
忘了有多久 2021-01-26 07:27

I new to C. I am reading a find-replace algorithm for C and I am a bit confused what the - & + operators do in this code:

char *re         


        
4条回答
  •  攒了一身酷
    2021-01-26 07:49

    it is a simple pointer arithmetics.

    buffer + i is the substring of buffer, that starts from the ith character [until the end]

    p - src is giving you the offset between p to src.

提交回复
热议问题