Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
DLang /
Include the content of a text fileLet's say we have a text file and we want to include its content in a string during compilation. $ cat lorem.txt Lorem ipsum dolor, molestiae quas vel numquam blanditiis.
The compilation is a bit tricky: $ dmd main.d main.d(6): Error: need `-J` switch to import text file `lorem.txt` static immutable string LOREM = import("lorem.txt").strip(); ^ $ dmd -J. main.d Why
Move the EXE to a different directory and execute it there: $ cat lorem.txt cat: lorem.txt: No such file or directory $ ./main Lorem ipsum dolor, molestiae quas vel numquam blanditiis. |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |