On Wed, 2010-06-30, Michael Torrie wrote: > On 06/29/2010 10:17 PM, Michael Torrie wrote: >> On 06/29/2010 10:05 PM, Michael Torrie wrote: >>> #include <stdio.h> >>> >>> int main(int argc, char ** argv) >>> { >>> char *buf = malloc(512 * sizeof(char)); >>> const int a = 2, b = 3; >>> snprintf(&buf, sizeof buf, "%d + %d = %d\n", a, b, a + b); >> ^^^^^^^^^^ >> Make that 512*sizeof(buf) > > Sigh. Try again. How about "512 * sizeof(char)" ? Still doesn't make > a different. The code still crashes because the &buf is incorrect.
I haven't tried to understand the rest ... but never write 'sizeof(char)' unless you might change the type later. 'sizeof(char)' is by definition 1 -- even on odd-ball architectures where a char is e.g. 16 bits. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . -- http://mail.python.org/mailman/listinfo/python-list