Write to file in a function
Ali Çehreli
acehreli at yahoo.com
Wed Oct 2 14:57:08 PDT 2013
On 10/02/2013 02:44 PM, Paul wrote:
> I would like to open a file before I enter a function and be able to
> write to it while I'm in the function. I'm not having any luck.
> Shared? Global? Pass a pointer to the funcion?
>
> auto fout = File("myfile.csv", "w"); is what I'm currently using.
>
> Thanks for any assistance.
import std.stdio;
void foo(File file)
{
file.writeln("my csv\n");
}
void main()
{
auto fout = File("myfile.csv", "w");
foo(fout);
}
Ali
More information about the Digitalmars-d-learn
mailing list