I am trying to print something on the console just by using the syscall write(). So far, it is more difficult than I thought.
The function is kept simple:
void writeOutput(char a, int64_t b, uint8_t c) {
char bNew[]; // what should be the size of that array=
while(b != 0x0000000000000000) {
int leftover = b%10;
bNew[i] = intToChar(leftover);
b = b/10;
i++;
}
}
char intToChar(int num) {
return '0' + num;
}
a should be formatted as char, b as a decimal number and c as an octal number.
For example a possible input is: writeOutput('a', -0xffff, 17); // ouput is "a -65535 21"
The the printed arguments should be separated by spaces and terminated by a newline to standard output. Also, I am trying to do that without the the functions of the sprintf-family. This makes it a little bit trickier.
EDIT: My question is: How is it possible to do that with write()? (Sry, missed that!) The code is online. EDIT2: My main problem is doing it without using the sprintf-family. I hoped you might help me.