Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
void main() {
|
||||
import std.stdio, std.file, std.string;
|
||||
auto file_lines = readText("input.txt").splitLines();
|
||||
//file_lines becomes an array of strings, each line is one element
|
||||
writeln((file_lines.length > 6) ? file_lines[6] : "line not found");
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import std.stdio;
|
||||
|
||||
void main() {
|
||||
int countLines;
|
||||
char[] ln;
|
||||
auto f = File("linenumber.d", "r");
|
||||
foreach (char[] line; f.byLine()) {
|
||||
countLines++;
|
||||
if (countLines == 7) {
|
||||
ln = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch(countLines) {
|
||||
case 0 : writeln("the file has zero length");
|
||||
break;
|
||||
case 7 : writeln("line 7: ", (ln.length ? ln : "empty"));
|
||||
break;
|
||||
default :
|
||||
writefln("the file only contains %d lines", countLines);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue