On Sat, 2009-03-21 at 00:27 +0100, Nicolas Joseph wrote: > Hello, > > > Attention, the function feof (in C) should not be used to check the > end of a file: http://c-faq.com/stdio/feof.html > > The correct code: > > [indent=2] > init > var f = FileStream.open("./main.gs","r") > var a = new array of char[2048] > while (f.gets(a) != null) > a[a.length - 1] = 0 /*make it null-terminated*/ > var ONELINE = (string)a /*caste array-of-char to a > string*/ > print "%s", ONELINE >
just to tidy the code up a bit, here is a slightly cleaner version : [indent=2] init var f = FileStream.open("./main.gs","r") var a = new array of char[2048] while f.gets(a) is not null a[a.length - 1] = 0 /*make it null-terminated*/ var ONELINE = (string)a /*cast array-of-char to a string*/ print ONELINE _______________________________________________ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list