I'm trying to write()
hexadecimal representation of
without any success.
The code I have ft_putstr_non_printable.c
:
#include <unistd.h>
void ft_putstr_non_printable(char *str)
{
int i;
unsigned char a;
char c;
i = 0;
a = 0x0;
while (str[i] != '')
{
if (str[i] <= 31 || str[i] == 127)
{
a = str[i];
write(1, &a, 1);
}
else
{
c = str[i];
write(1, &c, 1);
}
i++;
}
}
And main.c
:
#include <stdio.h>
#include <string.h>
#include "ft_putstr_non_printable.c"
int main(void)
{
char a[] = "
au revoira";
char b[] = "omellette du fromage";
char c[] = "coeuf@ca6vae fef";
char d[] = " Batata x7F rfg";
char e[] = "roquefort`[e{forte-e_tem,bolor
feff";
char f[] = " we 9are 78familly x1F rgfenf";
ft_putstr_non_printable(a);
ft_putstr_non_printable(b);
ft_putstr_non_printable(c);
ft_putstr_non_printable(d);
ft_putstr_non_printable(e);
ft_putstr_non_printable(f);
}
Am I doing something wrong? How do I get x0a?
Edit: I can't use printf()
. I'm limited to write()
.