mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Question about the printf()
@ 2024-10-10  1:37  .
  2024-10-10  1:51 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From:  . @ 2024-10-10  1:37 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]

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

 

[-- Attachment #2: Type: text/html, Size: 710 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] Question about the printf()
  2024-10-10  1:37 [musl] Question about the printf()  .
@ 2024-10-10  1:51 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2024-10-10  1:51 UTC (permalink / raw)
  To:  .; +Cc: musl

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..?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-10  1:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10  1:37 [musl] Question about the printf()  .
2024-10-10  1:51 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).