Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241010015138.GM10433@brightrain.aerifal.cx>
Date: Wed, 9 Oct 2024 21:51:38 -0400
From: Rich Felker <dalias@...c.org>
To: " ." <yedexi1996@...com>
Cc: musl <musl@...ts.openwall.com>
Subject: Re: Question about the printf()

On Thu, Oct 10, 2024 at 09:37:10AM +0800,  . wrote:
> Hi
> I have one question in printf.
> When I use printf to print data, I find that printf hides the data after '\0' when printing '\0'.
> 
> 
> int main()
> {
>     char c = '\0';
>     printf("c: %c , 111111 \n", c);
>     return 0;
> }
> As shown in the above code, musl library printing will only display "c:", and the following "11111" data will not be displayed. 
> Under mac and linux systems, the code will print "c:, 111111" completely.
> Best 
> ye

I get the expected output, including the 111111 and \n. Maybe you're
using a compiler that's making an invalid optimization (maybe
converting this printf to a puts even though that's not equivalent) or
something is hiding the output after the nul character from you..?

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.