Hi,
I don't use the Genie syntax but a working sample for vala is :
>>
using GLib;
public class SumCol {
public static it main(string [] args)
{
int MAXLINELEN = 128;
int sum = 0;
char[] str = new char [MAXLINELEN];
while(stdin.gets(str) != null)
{
sum += ((string)str).to_int();
}
stdout.printf("%d\n",sum);
return 0;
}
}
<<
You can simply cast a char array to string as the string class is only
a wrapper around NULL terminated unichar array.
2008/12/1 Barry Kauler <[EMAIL PROTECTED]>
>
> I'm learning Vala, using the Genie syntax, and I'm stuck on something.
> It would be great if a kind soul reading this would take a moment to
> help me out.
>
> I'm writing a console app and I want to read one line from the keyboard.
> The C function gets() seems to be the one, however I get this this far:
>
> var a = new array of char[64]
> stdin.gets(a)
>
> But what I really want is a string, and I don't know how to convert an
> array of chars to a string in Vala/Genie. Could someone tell me how?
>
> Note, I searched the vala-list but the only posts about stdin.gets
> show it used like this:
>
> stdin.gets(str, 256);
>
> so it must have got redefined at some time.
>
> Ah, it's so easy in Bash:
>
> read ONELINE
>
> Regards,
> Barry Kauler
> _______________________________________________
> Vala-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/vala-list
--
Clément DAVID
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list