Stephen Kairys
asked on
C: double percent sign (%%) in printf() statement (and question about %3.2f)
Hey all,
Need a sanity check here.
In this statement:
printf(,"Percent Completed %3.2f%%\r",percent);
Am I correct in deducing that the %% is necessary to display a percent sign, to avoid a single % from being taken to be a format specifier?
Yeah, I know I should know this, but I'm reviewing a C file to be sure that there are no mismatched format specifiers (b/c the program occasionally crashes) and want to be sure this statement is OK.
In addition, is the %3.2f format specifier OK for a double, as well as a float? (This question applies to both 16-bit and 32-bit).
Thanks
Steve
Need a sanity check here.
In this statement:
printf(,"Percent Completed %3.2f%%\r",percent);
Am I correct in deducing that the %% is necessary to display a percent sign, to avoid a single % from being taken to be a format specifier?
Yeah, I know I should know this, but I'm reviewing a C file to be sure that there are no mismatched format specifiers (b/c the program occasionally crashes) and want to be sure this statement is OK.
In addition, is the %3.2f format specifier OK for a double, as well as a float? (This question applies to both 16-bit and 32-bit).
Thanks
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the speedy and helpful responses! Have a good evening.
-Steve
-Steve
You're welcome! :)
ASKER
>>In addition, is the %3.2f format specifier OK for a double, as well as a float? (This question >>applies to both 16-bit and 32-bit).
Thanks again.
Steve