www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D.gnu - File example

↑ ↓ ← manfred toppoint.de writes:
Hi, 
 
import stream; 
import c.stdio; 
 
int main (char[][] args) { 
    File
dst = new File(); 
    dst.create("new_file"); 
    dst.writeString("Hi");
return 0; 
} 
 
I get the following errors, 
 
hansen hansen-lx:~/d/dli-0.1.2$
/file_write  
32727 3.272748e+04 
Permission denied 
Dumping core
Gleitkomma-Ausnahme 
 
----------    1 hansen   hansen          0 10. Apr 09:35
new_file 
 
Have someone a better example. Is it possible by  dst.create() to
change 
the mode, for example 777 . 
And how can i open a file for "read, write
or append"? 
 
Best Regards  
Manfred Hansen  
 
Apr 10 2003
↑ ↓ → Manfred Hansen <manfred toppoint.de> writes:
Hello,

this program read and write a file to disk.

import stream;
import c.stdio;

int main() {
        FILE *fpr;

        File kwd = new File("TODO"), dst = new File();
        fpr=fopen("test.txt","a");

        while (!kwd.eof()) {
                fprintf(fpr,kwd.readLine()~"\n","test.txt");
        }

        kwd.close;
        if((fclose(fpr)) != 0) {
                perror("fclose"); /* Reaktion auf Fehler */
        }

        return 0;
}

Regards,
Manfred Hansen
Apr 11 2003