mirror of
https://github.com/UberGuidoZ/Flipper.git
synced 2024-12-23 15:00:13 +00:00
57 lines
840 B
C
57 lines
840 B
C
//
|
|
// Tools for USB HID Autofire
|
|
//
|
|
|
|
void strrev(char* arr, int start, int end) {
|
|
char temp;
|
|
|
|
if (start >= end)
|
|
return;
|
|
|
|
temp = *(arr + start);
|
|
*(arr + start) = *(arr + end);
|
|
*(arr + end) = temp;
|
|
|
|
start++;
|
|
end--;
|
|
strrev(arr, start, end);
|
|
}
|
|
|
|
char *itoa(int number, char *arr, int base)
|
|
{
|
|
int i = 0, r, negative = 0;
|
|
|
|
if (number == 0)
|
|
{
|
|
arr[i] = '0';
|
|
arr[i + 1] = '\0';
|
|
return arr;
|
|
}
|
|
|
|
if (number < 0 && base == 10)
|
|
{
|
|
number *= -1;
|
|
negative = 1;
|
|
}
|
|
|
|
while (number != 0)
|
|
{
|
|
r = number % base;
|
|
arr[i] = (r > 9) ? (r - 10) + 'a' : r + '0';
|
|
i++;
|
|
number /= base;
|
|
}
|
|
|
|
if (negative)
|
|
{
|
|
arr[i] = '-';
|
|
i++;
|
|
}
|
|
|
|
strrev(arr, 0, i - 1);
|
|
|
|
arr[i] = '\0';
|
|
|
|
return arr;
|
|
}
|