'using printf and write together

I would like to understand why when I execute this code

#include <stdio.h>
#include <unistd.h>

int main()
{
    write(1, "6", 1);
    printf(" | ");
    write(1, "6", 1);
}

I get this output

66 | %

Instead of

6 | 6%

even with sleep before and after the printf it doesn't fix it. Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source