1 Reply Latest reply on Dec 3, 2019 11:20 PM by JayakrishnaT_76

    FX3 - How to use sprintf function?


      Hi all:


      I want to use sprintf() in EZ USB Suite - FX3 FW, but it met compiler fail.

      I've added "#include <stdio.h>", but it still fail...



      Hope someone could provide any suggestion.

      Thanks a lot!



        • 1. Re: FX3 - How to use sprintf function?



          Please use the API CyU3PDebugStringPrint(); for implementing snprintf();. This API make use of following parameters as shown in its definition.


          extern CyU3PReturnStatus_t

          CyU3PDebugStringPrint (

                  uint8_t *buffer,                          /**< Buffer into which the data is to be printed. */

                  uint16_t maxLength,                /**< Buffer size. */

                  char    *fmt,                              /**< Format specifier string. */

                  ...                                             /**< Variable argument list. */



          I have implemented your requirement as shown below.


          char c1[20];

          uint8_t n =5;

          CyU3PDebugStringPrint ((uint8_t*)c1, 20, "He has %d books.\n", n);



          I got the following output in teraterm.


          Best Regards,


          1 of 1 people found this helpful