I'm trying to print a few lines from the C-part of my program, but it seems that there is some limit as to how much I can print? Can Anyone tell me why? Using simple trivial code, called a few hundred times:
void printit() { int i; printf(buf,"%d ",perm); for(i = 0; i < talks; i++) printf("%d ",res_a[i]); printf("\n"); }
If I run this in the shell it works fine (I get a ton of output)...
If I pipe it trough wc I get:
$perl test.pl | wc 46 2859 8192
I then tried to call the output function twice for every time i would call it othervise and puf:
$ perl test.pl | wc 113 7164 20480
As in I get the full output (twice) Why the sudden succes?!?

Ok so I must hit some magic barrier, but I cant find any other who have the same problem or any kind of documentation that would explain it. If I add an extra printf("                                                                           \n")(lots of spaces) it works.
As a second choice I then tried to call a perlfunction which print, but that keeps segfaulting?
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]; }


T I M T O W T D I

In reply to Inline::C output with printf problem by Cine

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.