Link to home
Start Free TrialLog in
Avatar of Stephen Kairys
Stephen KairysFlag for United States of America

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
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stephen Kairys

ASKER

Thank you. And to this question:

>>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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the speedy and helpful responses! Have a good evening.
-Steve
You're welcome! :)