Delta_G:
byte someArray[] = {48, 48, 50, 51,0}; //0,1,2,3 in ASCII plus null terminator
--> missing some [] brackets for the array.
Alternatively if you don't have the trailing null character you can do something like this
byte someArray[] = {51, 50, 49, 48}; //3,2,1,0 in ASCII NO null terminator
unsigned long val = 0;
for (byte i = 0; i < sizeof(someArray); i++) val = 10 * val + (someArray[i] - '0');
then val is your value and in that case will be 3210
i3dm:
i tried this:
int Batt_Volt3 = atoi ((char*)buff[idx]));
where buff is my buffer of type BYTE.
--> atoi() expects a c string as parameter (a null terminated string of chars)
Delta_G:
You want a pointer to the array. So you either have to lose the [idx] or put a * in front of buff.
both methods still create errors - would you mind posting the line as it should be in the code?
also what will be the value of Batt_Volt3 after this conversion?
My array is comma seperated between numbers, and their values change from 1-6 digits, so i guess one digit at a time would be effective.
Anything else we need to know about your array and you forgot to mention?
Looks like you want to parse a string made up of different integers, comma separated. Is that the case? What do you know about the string? fixed number of elements? Max size of the int? can they be negative? atoi(), strtok(), sscanf,... many ways to skin that cat