Question: I'm trying to convert the characters to unsigned short but the value I'm getting in m\_cmdCode is always 0. Some input would be very helpful.

```
int main()
{
 char *temp = new char[3];
 memset(temp,1,3);
 unsigned short m_cmdCode = (unsigned short) atoi(temp);
 printf("%d",m_cmdCode);
}

```

// I want m\_cmdCode to be equal to 111, is it possible to do this ?

Answer: 
You're setting the elements of `temp` to the integer value `1`. You want the character value `'1'`:

```
memset(temp, '1', 3);

```

Note that you also need to NUL-terminate `temp` for `atoi` to work reliably.
it's come from your memset, you put 3 bytes with value 1 it's not the same thing than writing

```
strcpy(temp, "111")

```

maybe I reversed the src and dest