I needed to dynamically generate a string like the following:
001 / 192
However , the number of digits varies , thus i must define another variable , called print_width , which is , in this case: 192 % 10
snprintf ( statusString , 30 , "%0*d / %0*d" , snprintf_width , completed[tid] , total[tid]);
The code above posed a compiler warning: too few arguments , and not working
You need an integer width argument for each
*as well as for eachdin the format. You’ve provided 3 of the requisite 4 arguments, and your compiler is kind enough to tell you, rather than producing garbage at run time.Hence, for example: