I have been using some C code I found online, which had compiler warnings with codeblocks on windows 7, as I am learning C and trying to understand the code as part of the learning process I decided to look at the warnings and fix them a few where simple enough, however the first block I fixed I think I understand, but would be grateful if someone could confirm my understanding, the original code snippet in question is
unsigned char buffer[MAX_PATH];
unsigned char text_to_send[MAX_PATH];
unsigned char digits[MAX_PATH];
// example warning with digits when used as below
text_to_send[m] = strtol(digits, NULL, 16);
The warning given is
warning: pointer targets in passing argument 1 of 'strtol' differ in signedness [-Wpointer-sign]|
with a note note: expected 'const char *' but argument is of type 'unsigned char *'
The warning and note is correct to my understanding as digits used on it's own is a constant pointer to the address of digits[0]. When I remove the unsigned declarations and leave them as just type char, the compiler no longer issues warnings when these 3 arrays are used.
My question is that I can see no reason to use unsigned char digits[MAX_PATH] (or for the two declarations which give similar errors], but am I missing something, does the original author know something I have missed?
The code now compiles warning free and works seemingly the same, any input greatly appreciated.