On Sunday, 7 May 2017 at 16:40:50 UTC, k-five wrote:
On Sunday, 7 May 2017 at 15:59:25 UTC, JV wrote:
[...]

        [...]

--------------------------------------------------------------

You have the right for confusing :) there is many read and write names. But I assumed you are familiar with [Type] and [Object] concept.

in:
auto output_file_stream = File( "file.txt", "w" );

auto = File              == A type
File( "file.txt", "w" ); == Constructor

So this type has its own property, like read for "r" mode and write for "w" mode.

So you should use output_file_stream.write(), not readf or so on.

Still I am very new in D, but this is the same concept in other language like C++

in C++:
#include <iostream>
#include <fstream>
#include <string>

int main(int argc, char **argv)
{
        
        std::ofstream ofs( "file.txt" );
        std::string line = "This is the first line";
        // write is a method in class ofstream
        ofs.write( &*line.begin(), line.length() );
        ofs.close();
}

Yeah i understand it very much like the other language like C/C++ and python.. since i'm self studying D language ..though i learn faster when there is a sample code i don't know if it is rude but can i ask if you can give me a sample code for it? a code for asking the user to enter something and then store it in a .txt file?

Thank you

Reply via email to