I wrote the attached code with the intention to get 42 as the output but I instead get an asterisks (*) I know that 42 is the ACII value of an asterisk. Please look at my code and see something I might have missed. The program is in C using the <unistd.h> library, I have to use the unistd.h and not the stdio.h for this code.
[code]
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
void ft_putnbr(int nbr)
{
write(1, &nbr, 1);
}
void ft_ft(int *nbr)
{
*nbr = 42;
}
int main(void)
{
int a;
int *ptr;
char c;
a = 7;
ptr = &a;
ft_ft(ptr);
ft_putnbr(a);
ft_putchar('\n');
}
/code]
Our community of experts have been thoroughly vetted for their expertise and industry experience.