Write to file in a function

Adam D. Ruppe destructionator at gmail.com
Wed Oct 2 14:57:05 PDT 2013


On Wednesday, 2 October 2013 at 21:44:37 UTC, Paul wrote:
> auto fout = File("myfile.csv", "w"); is what I'm currently 
> using.

You should be able to just pass fout to a function normally:

void writeTo(File fout) {
    fout.writeln("info,here,etc");
}

void main() {
    auto fout = File("myfile.csv", "w");
    writeTo(fout);
}


More information about the Digitalmars-d-learn mailing list