Cine has asked for the wisdom of the Perl Monks concerning the following question:
If I run this in the shell it works fine (I get a ton of output)...void printit() { int i; printf(buf,"%d ",perm); for(i = 0; i < talks; i++) printf("%d ",res_a[i]); printf("\n"); }
$perl test.pl | wc 46 2859 8192
As in I get the full output (twice) Why the sudden succes?!?$ perl test.pl | wc 113 7164 20480
void printit() { Inline_Stack_Vars; Inline_Stack_Reset; int i; int howmuch; char buf[1000]; howmuch = sprintf(buf,"%d ",perm); for(i = 0; i < talks; i++) { howmuch+=sprintf(buf+howmuch,"%d ",res_a[i]); } buf[howmuch-1] = '\n'; Inline_Stack_Push(newSVpvf("%s",buf)); Inline_Stack_Done; perl_call_pv("main::printme",0); Inline_Stack_Void; } In Perl: sub printme { print for $_[0]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inline::C output with printf problem
by sgifford (Prior) on Jul 04, 2003 at 04:33 UTC | |
by Cine (Friar) on Jul 04, 2003 at 12:19 UTC |