c++ - comparing strings when 1 string contains part of the other string -


i using following code compare packetbuffer string,

char packetbuffer[udp_tx_packet_max_size]; !strcmp(packetbuffer, "turn on light") 

however how use compare string should packetbuffer = testing1234 , string compared equal "testing", out last 4 digits?

the function looking strstr:

if (strstr(packetbuffer, "testing") != null) {     // packetbuffer contains "testing"     // something... } 

note: if need test substring @ start of string can this:

if (strstr(packetbuffer, "testing") == packetbuffer) {     // packetbuffer starts "testing"     // something... } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -