Re: [Vala] Is this a bug or a feature?
- From: Jamie McCracken <jamie mccrack googlemail com>
- To: gege2061 redaction-developpez com
- Cc: Vala-list gnome org
- Subject: Re: [Vala] Is this a bug or a feature?
- Date: Fri, 20 Mar 2009 20:26:03 -0400
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]