First off, you have BUFFERSIZE implying that it is a global. You can make the length this as well and it will be the same size.
If you are looking for variable lengths in the response, you will need to use strlen()
size_t strlen(const char *s);
The strlen() function computes the number of bytes in the string to which s points, not including the terminating null byte.
The strlen() function returns the length of s; no return value is reserved to indicate an error.
This is assuming that there is a null terminator '\0' that you received from or with your input. In the case of strings with c, the following string "Hi" can be see as a char array {'H', 'i', '\0'}. If you do not have the null terminator, then I am not sure how to handle varying lengths unless there is a return value or int you can set with a function.
Edit
Additionally, if you are looking for the hex value of a char or an int is also important as they are not the same. In your example, the user input "4" and you are presenting the hex value of the character '4' and then the null terminator '\0'. If you are wanting to present the hex value of the number 4 then you need to convert the string to an integer with:
int atoi(const char *str);
or:
(int) strtol(str, (char **)NULL, 10);
Then you can display the hex value for the number. This is assuming that the information provided by the user is an integer value. If it is not expected to be, then just looking at the string is probably your best bet.