i have a difficulty with strtol() function in C, here's a piece of code of how i'm trying to use it
char TempChar;
char SerialBuffer[21];
char hexVoltage[2];
long intVoltage;
do
{
Status = ReadFile(hComm, &TempChar, sizeof(TempChar), &NoBytesRead, NULL);
SerialBuffer[i] = TempChar;
i++;
}
while (NoBytesRead > 0);
memcpy(hexVoltage, SerialBuffer+3, 2);
intVoltage = strtol(hexVoltage, NULL, 16);
So the question is why does strtol() returns 0 ? And how do i convert char array of values in hex to int (long in this particular case)? hexVoltage in my case contains {03, 34} after memcpy(). Thanks in advance. Really appreciate the help here.