Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int myItoa(uint8_t i, char* str, int size) {
- int j = size - 1;
- for(; i && j ; j--, i /= 10)
- str[j] = "0123456789"[i % 10];
- return j;
- }
- int myItoa2(int8_t i, char* str, int size) {
- int j = size - 1;
- int icpy = i < 0 ? -i : i;
- for(; icpy && j ; j--, icpy /= 10)
- str[j] = "0123456789"[icpy % 10];
- if (i < 0)
- str[j--] = '-';
- return j + 1;
- }
- void write3( char a, uint8_t b, int8_t c )
- {
- /* your code goes here */
- write(1, &a, 1);
- write(1, "\n", 1);
- char str[32];
- int index = myItoa(b, str, 32);
- write(1, str + index, 32 - index);
- write(1, "\n", 1);
- index = myItoa2(c, str, 32);
- write(1, str + index, 32 - index);
- write(1, "\n", 1);
- /* avoid 'unused parameter' warning */
- (void)a;
- (void)b;
- (void)c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement