Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Small D program to do some stuff with a file.
* Pseudocode
* Read Infomation on what needs to happen from the user
* Open file
* Read each line of the file to an array of strings
* Apply operations to array of strings
* Write each element of the array to the file
* Syntax:
* Arguments go in this order: Input File, Output file, Prefix, Suffix
import std.stdio, std.file, std.string;
string readString (string text) {
string stringOut;
string output = strip(readln());
return stringOut;
int main(string[] args) {
File inFile, outFile;
string inLine;
string prefix = readString("What do you want before each line of the file? ");
string suffix = readString("What goes at the end of each line?");
string input = readString("What file do we apply this operation to?");
string output = readString("What file do we dump this operation to?");*/
string input = args[1];
string output = args[2];
string prefix = args[3];
string suffix = args[4];
try {
inFile = File(input, "r");
} catch (std.exception.ErrnoException) {
writeln("We can't read that file!");
return 1;
outFile = File(output, "w");
while (!inFile.eof()) {
inLine = strip(inFile.readln());
outFile.writeln(prefix, inLine, suffix);
return 0;

This comment has been minimized.

Copy link

@Campinator Campinator commented Apr 8, 2017

You missed a change to name it Appen.d....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment