Int display problem

I’m having a bit of trouble displaying some data. Frankly, the problem seems a bit confound, which probably means that the solution is really elementary and I’ve succeeded in completely overlooking it.

Here it is:

The following code is supposed to display info stored in xmem, and it does, for the most part. The problem is that when it goes to display samp (an unsigned integer) a seemingly random number displays before samp.

If samp = 1, the number that gets displayed is something like “51” or “111” or “61”.
If samp = 47, the number that gets displayed is something like “147” or “647”, etc.

This didn’t make sense to me, so I added the

sprintf(outstr,"sample size: %u
", samp);
                           serBputs(outstr);

which displays samp correctly.


if (chr==13 && pccount == 6 && strncmp(pcchar, "infob", 5) ==0)
               {
                     xmem2root(&headcount,add_header,2);  //get # of blocks

                     if(headcount==0)
                      	textout("There are no blocks currently indexed.
");

                     if(headcount>0)
                     {
                     	sprintf(outstr,"Block #,START:month,day,year,hour,min,sec,channels,stat,n,sample
");
                     	serBputs(outstr);

                        for(tmpuint=0;tmpuint

I figured it out. All I had to do was place the entire offending sprintf call on one line, which, of course, makes perfect sense.