Hi all,
I got a requirement of changing the display string in one of the application. It is something like changing "90 percentage CPU" to "90% CPU". First, i did the fix in one of the printf by doing
printf("%d\% CPU",per);
Then, i need the same changes under sprintf so i tried
sprintf(str,"\%%s","CPU");
But, when i tried to print the "str" i am getting the result as %s. So, i searched and found in some forum they suggested to use double % symbol like the following
sprintf(str,"%%%s","CPU");
With this change it is correctly printing %CPU. Can someon explain me how this intertpretation works under sprintf?
-BalaC-



LinkBack URL
About LinkBacks


