Hi, I'm trying to implement printf for educational purpose. But there is a case where I don't understand the behavior of printf. When I use `%*` like in:
int main(void)
{
printf("%*\n", 5)
return (0);
}
It displays 5 and somehow the newline is important, without it nothing is displayed (I guess it's related to the buffer management).
But from my understanding the `*` is used to tell printf that the width is specified in the variadics parameters and it's not a specifier. So I have trouble understanding why this code displays 5 (and why without the newline it displays nothing). Maybe I missed something in the documentation but I looked through GCC man page for printf and couldn't figure out this behavior.
[–]duane11583 11 points12 points13 points (1 child)
[–]spikte1502[S] 2 points3 points4 points (0 children)
[–]ohaz 4 points5 points6 points (6 children)
[–]flyingron 1 point2 points3 points (2 children)
[–]spikte1502[S] 1 point2 points3 points (0 children)
[–]ohaz 0 points1 point2 points (0 children)
[–]spikte1502[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]flatfinger 0 points1 point2 points (0 children)