Re: [Vala] printing int64 value to standard output



%lld is not portable. your code will not work on windows.

the portable way is:

void main() {
        uint64 ts = 123;
        stdout.printf ("%"+uint64.FORMAT_MODIFIER;+"d\n", ts);
}


On 05/14/12 20:30, jezra wrote:
On Mon, 14 May 2012 14:14:47 -0400
"D.H. Bahr"<dbahr uci cu>  wrote:

Thanks!!
El lun, 14-05-2012 a las 10:20 -0700, Abhijit Hoskeri escribió:
On Mon, May 14, 2012 at 10:09 AM, D.H. Bahr<dbahr uci cu>  wrote:
Hello there, how can I print an int64 variable to stdout??

int64 timestamp = 1234151912;
stdout.printf("%?", timestamp);

%lld is the format string you need.

Regards,
Abhijit

10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS
INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci
Another option is to use Vala string templates:
int64 timestamp = 1234151912;
stdout.printf(@"$timestamp\n");

more examples of using string templates is available at:
http://live.gnome.org/Vala/StringSample
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]