Question: I created a function for this:

```
int SIGN_CHECKER (char* x)
{
    if(*x == '!')
    {
        return 1;
    } else if(*x == '?')
    {
        return 1;
    } else if(*x == '^')
    {
        return 1;
    } else if(*x == '&')
    {
        return 1;
    } else if(*x == '%')
    {
        return 1;
    } else
    {
        return 0;
    }
}

```

But as you can see, it's not that efficient. Does anybody know a better way?

Answer: 
The typical execution speed over memory use optimization is to create a simple look-up table.

```
#include <stdbool.h>

int sign_checker (char x)
{
  static const bool is_special [256] = 
  {
    ['!'] = true,
    ['?'] = true,
    ['^'] = true,
    ['&'] = true,
    ['%'] = true,
  };

  return is_special [(unsigned char)x];
}

```

x86 machine code is very efficient (gcc -O3):

```
SIGN_CHECKER:
        movsx   rdi, dil
        movzx   eax, BYTE PTR is_special.0[rdi]
        ret
is_special.0:
        .zero   33
        .byte   1
        .zero   3
        .byte   1
        .byte   1
        .zero   24
        .byte   1
        .zero   30
        .byte   1
        .zero   161

```
For starters the declaration of the function parameter having the type `char *` does not make a sense because only one character is checked within the function.

The function can be declared and defined the following way

```
#include <string.h>

//...

int SIGN_CHECKER( char c )
{
    return c != '\0' && strchr( "!?^&%", c );
}

```

As you can see it is enough to write just one line within the function.