any existing function to do that in c?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
sprintf with formatting codes like %02d will give you two decimal places.
here’s an example of the command
sprintf( string, “file.%d”, file_number );
Here it puts the string “file.2” into the variable named string, assuming that 2 was in the variable named file_number.
you can use multiple like so:
sprintf(str, “%02d/%02d/%4d”,day,month,year);
Look up the specs on sprintf for other kinds of formatting like floating point significant digits.