Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (aCondition) {
- // Предполагается, что объект файла был создан и используется здесь.
- // ...
- } // ← Автоматически файл будет закрыт здесь при выходе из области видимости.
- // Нет необходимости закрывать его вручную.
- file.close();
- file.open("student_records", "r");
- writeln("hello"); // запись в стандартный вывод
- stdout.writeln("hello"); // тоже что и выше
- file.writeln("hello"); // запись в файл
- while (!file.eof()) {
- /* ... */
- }
- import std.file;
- // ...
- if (exists(fileName)) {
- // есть файл или каталог под этим именем
- }
- else {
- // нет файла или каталога под этим именем
- }
- import std.stdio;
- void main()
- {
- File file = File("student_records", "w");
- file.writeln("Name : ", "Zafer");
- file.writeln("Number: ", 123);
- file.writeln("Class : ", "1A");
- }
- import std.stdio;
- import std.string;
- void main()
- {
- File file = File("student_records", "r");
- while (!file.eof()) {
- string line = chomp(file.readln());
- writeln("read line -> |", line);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement