0
char cTime[22];

sprintf(cTime, "%04s/%02s/%2s:%02s:%02s:%02s", year(), month(), day(), hour(), minute(), second());

This sprintf line causes this error:**B0100000063f694Š

Could someone help me debug this? Thank you.

2 Answers 2

1

%s is string macro but output of year(),... is probably an integer type. Use %d or %u macros in format.

0
0

Yes - try making each of the %-specifiers match the kind of conversion you want for each variable in the rest of the call. F/ex, %d converts an integer to a string in decimal radix, %f converts a double to a number with a decimal fraction, etc. In all cases, the output will be as characters; you don't need to specify that.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.