Search code examples
c++carduinowildcardstrcmp

Numerical wildcard when using strcmp C/C++ for Arduino


I'm trying to compare two string with strcmp, for arduino.

I just wondered if there was a C/C++ /Arduino wild card for a number.

My input will be LP followed by 5 unknown digits.

E.g. something like

a_string[]="LP*****";

if( strcmp(input,a_sting) == 0 )
{
    // run this
}

Solution

  • int i,j,k,l,m;
    if(strlen(input)==7 &&
       sscanf(input, "LP%1d%1d%1d%1d%1d", &i,&j,&k,&l,&m)==5)
    {
        //run this
    }