On Fri, Apr 13, 2012 at 12:10 PM, Mic <[email protected]> wrote:

> Hello,
> Is this the best and fastest way to read a file line by line?
>

> *static int main (string[] args) {*
> *  FileStream infile;*
> *  infile = FileStream.open(args[1], "r");*
> *  char buffer[1024];*
> *  int count = 0;*
> *  while (!infile.eof()) {*
> *    infile.gets(buffer);*
> *    count++;*
> *  }*
> *  stdout.printf("%i\n",count);*
> *  return 0;*
> *}*
>

Your code is buggy. See:
http://valadoc.org/#!api=glib-2.0/GLib.FileStream.read_line

-- 
www.debian.org - The Universal Operating System
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to