#include <unistd.h>
#include <stdio.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
int ft_sizeof_str(char *str)
{
int cntr;
cntr = 0;
while(str[cntr] != 0) /*ASCII 0 is the null character ('\').*/
{
cntr++;
}
return (cntr);
}
void ft_putstr(char *str)
{
/*guard against zero lenght strings*/
while(ft_sizeof_str(str) !=0)
{
int cntr;
cntr = 0;
while(str[cntr] != 0)
{
//ft_putchar(cntr++); /*try this but comment the cntr++ line below first!*/
ft_putchar(str[cntr]);
cntr++;
}
}
}
int main() {
//printf("Hello world!\n");
//ft_putstr("Hello world!");
int i = ft_sizeof_str("123");
printf("sizeof_str: %d", ft_sizeof_str("1234567890"));
ft_putstr("1234567890");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: