| ... | ... | @@ -264,15 +264,14 @@ |
| 264 | 264 | please <a href="https://github.com/zig-lang/www.ziglang.org/issues/new?title=I%20searched%20for%20___%20in%20the%20docs%20and%20didn%27t%20find%20it">file an issue</a> or <a href="https://webchat.freenode.net/?channels=%23zig">say something on IRC</a>. |
| 265 | 265 | </p> |
| 266 | 266 | <h2 id="hello-world">Hello World</h2> |
| 267 | | <pre><code class="zig">const io = @import("std").io; |
| 267 | <pre><code class="zig">const std = @import("std"); |
| 268 | 268 | |
| 269 | 269 | pub fn main() -&gt; %void { |
| 270 | 270 | // If this program is run without stdout attached, exit with an error. |
| 271 | | var stdout_file = %return io.getStdOut(); |
| 272 | | const stdout = &amp;stdout_file.out_stream; |
| 271 | var stdout_file = %return std.io.getStdOut(); |
| 273 | 272 | // If this program encounters pipe failure when printing to stdout, exit |
| 274 | 273 | // with an error. |
| 275 | | %return stdout.print("Hello, world!\n"); |
| 274 | %return stdout_file.write("Hello, world!\n"); |
| 276 | 275 | }</code></pre> |
| 277 | 276 | <pre><code class="sh">$ zig build-exe hello.zig |
| 278 | 277 | $ ./hello |