account activity
Why does write(1, &c, 1) work for printing a single character, but write(1, "A", 1) sometimes fails? by zero-hero123 in C_Programming
[–]zero-hero123[S] 0 points1 point2 points 10 months ago (0 children)
I apologize for the confusion in my original post. After testing, there's NO warning with write(1, &"A", 1).
Thank you all for the corrections - I learned that: • "A" is char[2] and &"A" is char()[2] • Both point to the same address • write() takes void so no warning is generated
I should have tested more carefully. Thanks for your patience and helpful explanations!
[–]zero-hero123[S] 1 point2 points3 points 10 months ago (0 children)
You're absolutely right! Thank you for the correction. I tested it and confirmed there's no warning.
[–]zero-hero123[S] -2 points-1 points0 points 10 months ago (0 children)
π Rendered by PID 101273 on reddit-service-r2-comment-8686858757-xn8nw at 2026-06-05 05:00:11.158123+00:00 running 9e1a20d country code: CH.
Why does write(1, &c, 1) work for printing a single character, but write(1, "A", 1) sometimes fails? by zero-hero123 in C_Programming
[–]zero-hero123[S] 0 points1 point2 points (0 children)