1.5.24: gcc / libc problem with sscanf

Matteo Corti matteo.corti@id.ethz.ch
Tue Apr 17 14:25:00 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I get strange results when using the %zi flag for the sscanf and fscanf
functions.

The following code scans a line and parses an integer and a size_t value.

  size_t var_size_t = 0;
  int    var_int    = 0;

  char * string = "2 10";

  sscanf(string, "%zi %i\n", &var_size_t, &var_int);

  printf("size_t = %zi\n", var_size_t);
  printf("int    = %i\n",  var_int);

The code when compiled and run generates 2 followed by 0 instead of the
correct 2 and 10 (that I get on linux and mac os x).

Thanks,

Matteo

- --
Dr. Matteo Corti
ETH Zurich
Informatikdienste / Basisdienste
matteo.corti@id.ethz.ch
+41 44 6327944

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFGJNjALEG/T0gggJsRAoTlAJ9Vc9eV0rrWrKNP7E/6x6RxhDescgCeMRrT
sJwNf1SFVkgQ9D3S5FnnE5g=
=lGtz
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20070417/12d4510a/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.c
Type: text/x-csrc
Size: 307 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20070417/12d4510a/attachment.bin>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list