Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2024/25/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

Read the lines of a text file to a list of strings

See also std.file.

(1) read to list
def main():
    f = open("input.txt", "r")

    lines = f.read().splitlines()

    f.close()
import std.stdio;
import std.file; // readText()
import std.string; // splitLines()

void main()
{
    string[] lines = readText("input.txt").splitLines();

    writeln(lines);
}

Output:

$ cat input.txt
first line.
second line.
last line

$ rdmd main.d
["first line.", "second line.", "last line"]
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2025 June 28, 19:17