0

I have two variables:

  • dataRx (SLAVE::1234)
  • globalAuthcode (1234)

and I comparing

     if(strcmp(dataRx, globalAuthcode) == 0)

I can't find function like SUBSTR from PHP :) I want leve only 1234 from dataRx variable.

4

1 回答 1

1

Use pointer arithmetics:

strcmp(dataRx + 7, globalAuthcode)
/*           ^^^^ */

The dataRx + 7 skips over the first seven characters of the string. Of course, you might want to make sure that the string is at least 7 characters before doing that.

于 2013-10-07T12:23:01.373 回答