D - append line with stream on file
- Manfred Hansen (29/29) Apr 20 2004 Hello,
- Matthew (3/25) Apr 20 2004 Shouldn't you use an open() method? (I don't know; just guessing)
- Andrew (5/34) Apr 20 2004 Replaceing your first two lines with:
- Andrew (9/25) Apr 20 2004 Even Better:
- Ben Hinkle (3/11) Apr 20 2004 My std.stream "update" fixes that bug. File open will create if it isn't
- Andrew Edwards (4/16) Apr 20 2004 Must be in 0.82, I'm still stuck on 0.81 and tried it after I made my fi...
- Kris (8/29) Apr 20 2004 Andrew,
Hello, is it possible to append a line on a file with std.streams ? import std.stream; int main() { File file = new File; file.create("testfile.txt"); file.writeLine("Line 1"); file.close(); return 0; } If i run the programm twice, i have only one line in my file. In C looks like: #include <stdio.h> int main(void) { FILE* fp; fp= fopen("testfile.txt","a+"); fputs("Line 1",fp); fclose(fp); return 0; } I missed an append function in stream's . Manfred
Apr 20 2004
Shouldn't you use an open() method? (I don't know; just guessing) "Manfred Hansen" <manfred toppoint.de> wrote in message news:c63r3p$btu$1 digitaldaemon.com...Hello, is it possible to append a line on a file with std.streams ? import std.stream; int main() { File file = new File; file.create("testfile.txt"); file.writeLine("Line 1"); file.close(); return 0; } If i run the programm twice, i have only one line in my file. In C looks like: #include <stdio.h> int main(void) { FILE* fp; fp= fopen("testfile.txt","a+"); fputs("Line 1",fp); fclose(fp); return 0; } I missed an append function in stream's . Manfred
Apr 20 2004
In article <c63r3p$btu$1 digitaldaemon.com>, Manfred Hansen says...Hello, is it possible to append a line on a file with std.streams ? import std.stream; int main() { File file = new File; file.create("testfile.txt");Replaceing your first two lines with: File file = new File("testfile.txt",FileMode.Out); file.seekEnd(0); Should do the trick!file.writeLine("Line 1"); file.close(); return 0; } If i run the programm twice, i have only one line in my file. In C looks like: #include <stdio.h> int main(void) { FILE* fp; fp= fopen("testfile.txt","a+"); fputs("Line 1",fp); fclose(fp); return 0; } I missed an append function in stream's . Manfred
Apr 20 2004
In article <c64039$kmq$1 digitaldaemon.com>, Andrew says...In article <c63r3p$btu$1 digitaldaemon.com>, Manfred Hansen says...Even Better: File file = new File; try { file.open("testfile.txt",FileMode.Out); } catch (OpenError e) { file.create("testfile.txt",FileMode.Out); } file.seekEnd(0);Hello, is it possible to append a line on a file with std.streams ? import std.stream; int main() { File file = new File; file.create("testfile.txt");Replaceing your first two lines with: File file = new File("testfile.txt",FileMode.Out); file.seekEnd(0); Should do the trick!
Apr 20 2004
Even Better: File file = new File; try { file.open("testfile.txt",FileMode.Out); } catch (OpenError e) { file.create("testfile.txt",FileMode.Out); } file.seekEnd(0);My std.stream "update" fixes that bug. File open will create if it isn't there. -Ben
Apr 20 2004
Must be in 0.82, I'm still stuck on 0.81 and tried it after I made my first post. Needless to say: it didn't work. I'll download 0.82. Thanks... "Ben Hinkle" <bhinkle4 juno.com> wrote in message news:c643e8$q1c$1 digitaldaemon.com...Even Better: File file = new File; try { file.open("testfile.txt",FileMode.Out); } catch (OpenError e) { file.create("testfile.txt",FileMode.Out); } file.seekEnd(0);My std.stream "update" fixes that bug. File open will create if it isn't there. -Ben
Apr 20 2004
Andrew, Ben was talking about his *updated* version: it's not in the Phobos library (yet). Ben provided a download link for it a week or so ago, and I think this is probably the place: http://home.comcast.net/~benhinkle/stream.d - Kris "Andrew Edwards" <edwardsac spamfreeusa.com> wrote in message news:c645op$u1q$1 digitaldaemon.com...Must be in 0.82, I'm still stuck on 0.81 and tried it after I made myfirstpost. Needless to say: it didn't work. I'll download 0.82. Thanks... "Ben Hinkle" <bhinkle4 juno.com> wrote in message news:c643e8$q1c$1 digitaldaemon.com...Even Better: File file = new File; try { file.open("testfile.txt",FileMode.Out); } catch (OpenError e) { file.create("testfile.txt",FileMode.Out); } file.seekEnd(0);My std.stream "update" fixes that bug. File open will create if it isn't there. -Ben
Apr 20 2004