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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -