writeln and write - D Programming Language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Discord (community-run)
  - Forums
  - IRC
  - Wiki
  - Issues
  - Contributing
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# writeln and write

In the previous chapter we have seen that `writeln` takes a string within parentheses and prints the string.

The parts of programs that actually do work are called functions and the information that they need to complete their work are called parameters. The act of giving such information to functions is called passing parameter values to them. Parameters are passed to functions within parentheses, separated by commas.

Note: The word parameter describes the information that is passed to a function at the conceptual level. The concrete information that is actually passed during the execution of the program is called an argument. Although not technically the same, these terms are sometimes used interchangably in the software industry.

`writeln` can take more than one argument. It prints them one after the other on the same line:

    import std.stdio;

    void main() {
        writeln("Hello, World!", "Hello, fish!");
    }

Sometimes, not all of the information that is to be printed on the same line may be readily available to be passed to `writeln`. In such cases, the first parts of the line may be printed by `write` and the last part of the line may be printed by `writeln`.

`writeln` advances to the next line, `write` stays on the same line:

    import std.stdio;

    void main() {
        // Let's first print what we have available:
        write("Hello,");

        // ... let's assume more operations at this point ...

        write("World!");

        // ... and finally:
        writeln();
    }

Calling `writeln` without any parameter merely completes the current line, or if nothing has been written, outputs a blank line.

Lines that start with // are called comment lines or briefly comments. A comment is not a part of the program code in the sense that it doesn't affect the behavior of the program. Its only purpose is to explain what the code does in that particular section of the program. The audience of a comment is anybody who may be reading the program code later, including the programmer who wrote the comment in the first place.

##### Problemler

1. Both of the programs in this chapter print the strings without any spaces between them. Change the programs so that there is space between the arguments as in "Hello, World!".
2. Try calling `write` with more than one parameter as well.

... çözümler

Copyright © 1999-2026 by the D Language Foundation | Page generated by Ddoc on Wed Aug 5 15:38:51 2026