This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with sprintf

I have to following code:

//      Write screen
        n = sprintf( screen_msg,      " TV: %#4.1f  FV: %#4.1f  CV: %#4.1f  SV: %#4.1f\r\n", ad_value[2], ad_value[1], ad_value[0], ad_value[3] );
        n += sprintf( screen_msg + n, " TI: %#4.1f  AT: %#4.1f  CT: %#4.1f  ST: %#4.1f\r\n", ad_value[4], ad_value[5], ad_value[7], ad_value[6] );
        n += sprintf( screen_msg + n, "\r\n" );
        n += sprintf( screen_msg + n, "ENGINE      CHARGE     CLK EN      DIS" );

        write_0( screen_msg );

When the string is printed to my LCD CV, SV, and ST are always zero, regardless of the value in the ad_value array. If I print just those values in the same routine they appear as they should. When I debug the program the entire string appears as it should. My screen_msg buffer is 256 characters and the entire string in only 170.

I have looked over the code a dozen times and can't figure out what's going on. Can anyone see something that I may be missing?

Thanks,
Paul